Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: given-when construct unexpected bahavior wit arrays

by brx (Pilgrim)
on Jun 08, 2012 at 07:33 UTC ( [id://975103]=note: print w/replies, xml ) Need Help??


in reply to Re^3: given-when construct unexpected bahavior wit arrays
in thread given-when construct unexpected behavior with arrays

Yep, doing map {"_$_"} @array before each test, in given-when, is not good.

But grep works too much because if the first array element matches, you don't need to look others.

This is probably the fastest solution :

sub is_in_array2 { my $element = shift; ($element eq $_) && return 1 for @_; }

update: You should also try with an hash %is_in_array

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-20 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found