in reply to pattern matching
A nifty trick when your one-liners get out of hand is to use B::Deparse on it:
perl -MO=Deparse -lne 'print if s/0010 0010.*\/\/.*\/\///'
which gives you an approximation of what Perl runs:
LINE: while (defined($_ = <ARGV>)) { chomp $_; print $_ if s[0010 0010.*//.*//][]; }
This is some ugly code, so I'd rewrite that to be more sightly:
or, if you're interested in post-processing the lines in your script:#!/usr/perl -w use strict; while (defined(my $line = <ARGV>)) { chomp $line; print $line if s[0010 0010.*//.*//][]; }
#!/usr/perl -w use strict; my @interesting_lines = map { s[0010 0010.*//.*//][] ? $_ : ()} (<ARGV>); print "Name: $_" for @interesting_lines;
Update: Corrected last snippet to work like the previous snippets
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: pattern matching
by perlcgi (Hermit) on May 04, 2004 at 13:59 UTC |