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

Re: Speed comparison of foreach vs grep + map

by Corion (Patriarch)
on May 25, 2025 at 18:01 UTC ( [id://11165115]=note: print w/replies, xml ) Need Help??


in reply to Speed comparison of foreach vs grep + map

Without looking at your timings, the second script is doing something different than the first script:

my @e = grep(/0/, @d);

This invokes the regex engine instead of comparing $_ to falsy values.

Maybe you meant to write something like:

my @e = grep(!$_, @d);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2026-04-18 19:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.