Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Compare all array values without a loop

by Random_Walk (Prior)
on Oct 19, 2004 at 15:54 UTC ( #400568=note: print w/replies, xml ) Need Help??


in reply to Compare all array values without a loop

Just for fun here is an evil eval way to do it without a loop.

@a=('A', 'B', 'C', 'D'); $b='D'; if (eval "if(\$b eq \"".(join"\"){return 1}if(\$b eq \"",@a)."\"){retu +rn 1}") { Print "It was there\n" }

Cheers,
R.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2018-11-17 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (205 votes). Check out past polls.

    Notices?