in reply to Re: Re: Re: Shorten script
in thread Shorten script
I am often a chooser of elegance (subjective, of course) over efficiency.
So, to combine some efficiency with some elegance:
The $1 will be properly remembered -- although if a line matches both patterns is the or a short circuit operator? You might have to switch the order to keep the behavior identical.while($line = <F>) { for my $hit ($line =~ /matchPattern/gi) { $ct++; push @files, $name; print "PAGE ->\t$name\ndata ->"; if( $line =~ /(patternOne)/i or $line =~ /(patternTwo)/i ) { print "\t\t$1\nMATCHED - >\t$hit\n"; } else { print " TEXT INFO HERE.\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Shorten script
by sauoq (Abbot) on Jul 22, 2003 at 21:02 UTC | |
by snax (Hermit) on Jul 22, 2003 at 21:42 UTC |