in reply to Re^2: Map function slowing down program
in thread Map function slowing down program

It works with map as well as with grep.   Try it and see.

  • Comment on Re^3: Map function slowing down program

Replies are listed 'Best First'.
Re^4: Map function slowing down program
by ikegami (Patriarch) on Nov 17, 2008 at 03:45 UTC
    Yes and no. With map, it depends on the pattern.
    >perl -le"@rxs='(.)(.)'; $line = 'ab'; my $cnt = grep $line =~ $_, @rx +s; print $cnt" 1 >perl -le"@rxs='(.)(.)'; $line = 'ab'; my $cnt = map $line =~ $_, @rxs +; print $cnt" 2

    grep is more robust. It'll work with just about any expression, whereas map only works with very specific expressions.