Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • my $filename = shift;
    open(IN,$filename) || die "cannot open $filename for reading: $!";
    open(OUT,">$filename.out") || die "cannot open $filename.out for writing: $!";

    while ( <IN> ) {
        next if /\.(gif|jpg|css|GIF|JPG|CSS) HTTP/;
        next if /192\.(9|18|29)\./;
        print OUT;
    }
    Not sure about the execution speed of the regexes, but it's a damn sight easier to read.
    --

    --
    xoa

    • Tests? Should be /^192 and it should go faster if you use /o on the regexen.

      But, yeah, much easier to read, much faster to write, and much better.

      Hmm. I think I should ask pudge to make <tt> text a different colour.
      --
        ---ict / Spoon
      • it should go faster if you use /o on the regexen.

        No it won't. The /o only applies to regexes that are based on variables, as in:

        my $pattern = "192\.(whatever)";
        if ( $foo =~ /$pattern/o )
        That's the ONLY time that /o applies.
        --

        --
        xoa

    • Without wishing to wave the golf stick, may I commend
      #!perl -pi.out
      $_ = '' unless /(?:\.(?:gif|jpg|css|GIF|JPG|CSS)[ ]HTTP |
                         192\.(?:9|18|29)\.)/x
      to the house?