Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Fastest way to compare multiple variables?

by Masem (Monsignor)
on May 15, 2001 at 21:14 UTC ( #80624=note: print w/ replies, xml ) Need Help??


in reply to Fastest way to compare multiple variables?

TIMTOWODI:

if ( !grep { $_ != $a } ($b, $c, $d, $e...) ) { &do_something }

Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain


Comment on Re: Fastest way to compare multiple variables?
Download Code
Re: Re: Fastest way to compare multiple variables?
by Anonymous Monk on May 15, 2001 at 21:31 UTC
    Thank you for the suggesting code... it works well without using temporary arrays/hashes.

    By the way, what does TIMTOWODI mean?
      TIMTOWTDI - There Is More Than One Way To Do It
      TIMTOWODI - There Is More Than One Way Of Doing It
(ar0n) Re (2): Fastest way to compare multiple variables?
by ar0n (Priest) on May 15, 2001 at 21:55 UTC
    if ( @list == grep { $_ == $list[0] } @list ) { &do_something; }
    ... seems clearer to me. But then again, that's just me ;)

    ar0n ]

      if ( !grep $_ != $list[0], @list ) { &do_something; }
      ... probably clearer, definitely probably faster :)
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-09-17 01:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (56 votes), past polls