And by reverse the loops, he means change:
toforeach $term (@inputs) { while (<FILE>) {
while (<FILE>) { foreach $term (@inputs) {
I'm going to add a few unrelated points:
Always:
In fact, you probably have a bug of "filenumbers2" vs. "numbers2" that use strict would catch.use warnings; use strict;
Instead of
you should havepush @before, split(' ', $`);
Then you don't need the awkward @before = undef; The same holds for @after, too.@before = split(' ', $`);
Really it should be
The three linesmy @before = split /\s+/, $`;
are better written as splice(@before, 0, -7);. And this code:@before = reverse(@before); @before = splice(@before, 0, 7); @before = reverse(@before);
can be written asif(exists $results{$number}) { $existing = $results{$number}; $results{$number} = $existing . "... @before" . "<b>$&</b>" . "@afte +r ..."; } else { $results{$number} = "... @before" . "<b>$&</b>" . "@after "; }
$results{$number} .= "... @before" . "<b>$&</b>" . "@after ";
In reply to Re: Re: Pattern Matching With Regular Expressions
by Thelonius
in thread Pattern Matching With Regular Expressions
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |