ben@Tyr:~$ perl -we'@list = 1..24; print "'4' found at \$list[$_]\n" for 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" for grep { $list[$_] =~ /^4$/ } 0 .. $#list' 4 found at $list[3]