in reply to Re: Array searching, grep, first
in thread Array searching, grep, first
If you're going to use grep that way, you're doing unnecessary work. Either rewrite that grep as a for loop or use List::Util::first.
my $index; for ( 0 .. $#csvlist ) { if ( $csvlist[$_] =~ /$x/ ) { $index = $_; last; } } use List::Util 'first'; my $index = first { $csvlist[$_] =~ /$x/ } 0 .. $#csvlist
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Array searching, grep, first
by ChrisR (Hermit) on Sep 01, 2005 at 19:07 UTC |