use strict; use warnings; open my $fh,'<', 'input1.txt' or die; while (<$fh>) {print if /b/} #### aaa bbb ccc #### perl webperlizator.pl -s simple_reader.pl -i input1.txt https://webperl.zero-g.net/democode/perleditor.html#%7B%22script_fn%22%3A%22simple_reader.pl%22%2C%22script %22%3A%22use%20strict%3B%5Cnuse%20warnings%3B%5Cn%5Cnopen%20my%20%24fh%2C%27%3C%27%2C%20%27input1.txt%27%20or %20die%3B%20%5Cnwhile%20%28%3C%24fh%3E%29%20%7Bprint%20if%20%2Fb%2F%7D%22%2C%22inputs%22%3A%5B%7B%22text%22%3 A%22aaa%5Cnbbb%5Cnccc%5Cn%22%2C%22fn%22%3A%22input1.txt%22%7D%5D%2C%22cmdline%22%3A%22perl%20simple_reader.pl%22%7D #### use strict; use warnings; use URI::Escape; use Getopt::Long; use JSON::MaybeXS qw(encode_json); my (@infiles, @outfiles, $script, $lineofcode, $browse, $help); unless ( GetOptions ( "script=s" => \$script, "line|oneliner|code|c=s" => \$lineofcode, "inputfiles=s" => \@infiles, "outputfiles|o=s" => \@outfiles, "browse" => \$browse, "help" => \$help )) { print "GetOpt::Long returned errors (see above), available options:\n\n".help(); exit; } if ($help){ print help(); exit 0;} my $json = {}; if ($lineofcode){ $$json{cmdline} = "perl $lineofcode"; } elsif ($script){ open my $fh, '<', $script or die "unable to read $script!"; while (<$fh>){ $$json{script} .= $_ ; } $$json{script_fn} = $script; $$json{cmdline} = "perl $script"; } else{ die "Please feed at least one script using -script or a line of perl code via -code\n\n".help(); } if ( $infiles[0] ){ $$json{inputs}=[]; } foreach my $in (@infiles){ open my $fh, '<', $in or die "unable to read $in!"; my $file = { fn => $in}; while (<$fh>){ $$file{text}.=$_; } push @{$$json{inputs}},$file; } if ( $outfiles[0]){ $$json{outputs} = \@outfiles ; } my $url = 'https://webperl.zero-g.net/democode/perleditor.html#'.(uri_escape( encode_json( $json ) )); if ($browse){ if ($^O =~/mswin32/i) {exec "start $url"} else{ exec "xdg-open $url"} } else{ print $url; } #### sub help{ return <