Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Is there a way around grep?

by ikegami (Pope)
on Oct 11, 2011 at 02:35 UTC ( #930730=note: print w/ replies, xml ) Need Help??

in reply to Is there a way around grep?

if (grep {$_ eq $filename} @index_file_names) {

is basically the same as

my $found; for (@index_file_names) { ++$found if $_ eq $filename; } if ($found) {


Comment on Re: Is there a way around grep?
Select or Download Code
Re^2: Is there a way around grep?
by suaveant (Parson) on Oct 11, 2011 at 15:53 UTC
    Of course, if only looking for a match a good addition would be a last to break the loop as soon as a match is found.

    Or use List::Util::first

                    - Ant
                    - Some of my best work - (1 2 3)

      If you're looking for speed, I bet grep is normally faster than for+last.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930730]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (13)
As of 2015-03-28 13:20 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (625 votes), past polls