Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Fastest way to compare multiple variables?

by sierrathedog04 (Hermit)
on May 15, 2001 at 22:03 UTC ( #80652=note: print w/replies, xml ) Need Help??

in reply to Fastest way to compare multiple variables?

if (($a == $b) && ($a == $c) && ($a == $d) ... ){ &do_something }
Update: There seems to be no way to solve this problem without listing each variable by name, since we do not know the names of the variables. So listing them and doing simple equality tests is as maintainable and efficient as other approaches.

A solution that one writes in baby Perl can be just as valid as any other, in the same way that the lyrics to Louie, Louie were as great as those of Dylan's Mr. Tambourine Man, and the Ramones (R.I.P. Joey) were as great as the Beatles.

Replies are listed 'Best First'.
Re: Re: Fastest way to compare multiple variables?
by Anonymous Monk on May 15, 2001 at 23:14 UTC
    I was about to do that, however the TIMTOWTDI / TIMTOWODI spirit hinted me to ask here.

    By the way, what's 'baby Perl'??
      I would define "baby Perl" as any Perl that one can write using only the constructs set forth in the first chapter of Merlyn (Randal L. Schwartz)'s estimable Lhama book "Learning Perl." Thus, one could use print, if, chomp, <STDIN>and even qw and tr but not grep, map, hashes, typeglobs, references and the flipflop operator.

      I say, if you know baby Perl, you can do almost anything, just as if you know a thousand words of French and the present tense conjugations of verbs you can get by in Paris.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://80652]
[choroba]: but gurus say they in fact happen left to right, but we understand them wrongly
[marioroy]: bad gurus :)
[choroba]: also, &> redirects both at the same time
[marioroy]: erix are you using csh
Discipulus uh the link was for cmd.exe the bash one
[marioroy]: If yes, for redirection to work, one might do the following
[marioroy]: `bash -c "clang --version 2>/dev/null"`
[choroba]: Sane people don't use csh
[marioroy]: the 1>&2 will work, not shown
[marioroy]: sorry, did not know which if cmd.exe or unix (bash)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-03-23 08:21 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (284 votes). Check out past polls.