in reply to Re: Missing $ on loop variable
in thread Missing $ on loop variable
When I see a ternary used in that fashion, I can't help but imagine you're one step away from condensing that down to:
$line=~/$_/i&&push(@found,$_)for@keywords;
Myself, I'd expand it a bit:
for (@keywords) { next unless $line =~ /$_/i; push @found, $_; }
I think it's a bit clearer and more obvious what's going on. Nothing earth-shattering, but a lot of these kind of things can add up.
Update: then again, I might even go sideways on it:
my @found = grep { $line =~ /$_/i } @keywords;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Missing $ on loop variable
by psychotic (Beadle) on Dec 02, 2005 at 21:52 UTC | |
by revdiablo (Prior) on Dec 03, 2005 at 02:32 UTC | |
by psychotic (Beadle) on Dec 03, 2005 at 14:39 UTC | |
by revdiablo (Prior) on Dec 03, 2005 at 19:27 UTC |