in reply to Re: Finding values position in array
in thread Finding values position in array

I though of grep but when I checked the doc page (which is thin to say the least) I couldn't see a way of using it. Would you be kind enough to give an example?

Replies are listed 'Best First'.
Re^3: Finding values position in array
by oko1 (Deacon) on Apr 14, 2008 at 02:45 UTC
    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