ben@Tyr:~$ perl -we'@list = 1..24; print "'4' found at \$list[$_]\n" f +or grep { $list[$_] =~ /4/ } 0 .. $#list' 4 found at $list[3] 4 found at $list[13] 4 found at $list[23] ben@Tyr:~$ perl -we'@list = 1..24; print "'4' found at \$list[$_]\n" f +or grep { $list[$_] =~ /^4$/ } 0 .. $#list' 4 found at $list[3]
The first example matches '4' anywhere in the element; the second one is a precise match.
-- Human history becomes more and more a race between education and catastrophe. -- HG Wells
In reply to Re^3: Finding values position in array
by oko1
in thread Finding values position in array
by cosmicperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |