App-grepurl
view release on metacpan or search on metacpan
lib/App/grepurl.pm view on Meta::CPAN
}
elsif( @ARGV > 0 ) {
my $file = $opts->{t};
die "Could not read file [$file]!\n" unless -r $file;
$self->read_from_text_file( $file );
}
elsif( -t STDIN ) {
read_from_stdin();
}
else {
return;
}
}
sub read_from_url {
my( $self, $url ) = @_;
debug( "Reading from url" );
my $data = Mojo::UserAgent->new->get( $url )->result->body;
$data;
}
sub read_from_text_file {
my( $self, $file ) = @_;
debug( "Reading from file <$file>" );
my $data = do { local $/; open my($fh), $file; <$fh> };
$data;
}
sub read_from_stdin {
my( $self ) = @_;
print "Reading from standard input" if $self->{Either};
my $data = do { local $/; <STDIN> };
$data;
}
sub regex {
my( $self, $option ) = @_;
return unless defined $option;
my $regex = eval { qr/$option/ };
$@ =~ s/at $FindBin::Script line \d+.*//;
die "$FindBin::Script: $@" if $@;
$regex;
}
sub uncommify {
my( $self, $option ) = @_;
return {} unless defined $option;
return { map { $_, 1 } split m/,/, $option };
}
sub debug_summary {
my( $self ) = @_;
no warnings;
local $" = "\n\t";
my $opts = $self->{opts};
debug( <<"DEBUG" );
Version: $VERSION
Verbose: $self->{Verbose}
Debug: $self->{Debug}
Ascending: $opts->{a}
Descending: $opts->{A}
Unique: $opts->{1}
Image: $opts->{i}
Image(-): $opts->{I}
Javascript: $opts->{j}
Javascript(-): $opts->{j}
Hosts: $opts->{h}
@{ [ keys %{ $self->{Hosts} } ] }
Hosts(-): $opts->{H}
@{ [ keys %{ $self->{No_hosts} } ] }
Path: $opts->{p}
$self->{Path}
Path(-): $opts->{P}
$self->{No_path}
Regex: $opts->{r}
$self->{Regex}
Regex(-): $opts->{R}
$self->{No_regex}
Scheme: $opts->{s}
@{ [ keys %{ $self->{Schemes} } ] }
Scheme(-): $opts->{S}
@{ [ keys %{ $self->{No_schemes} } ] }
DEBUG
}
1;
( run in 0.664 second using v1.01-cache-2.11-cpan-af0e5977854 )