Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Fastest way to compare multiple variables?

by zeidrik (Scribe)
on May 16, 2001 at 11:58 UTC ( #80825=note: print w/replies, xml ) Need Help??


in reply to Re: Fastest way to compare multiple variables?
in thread Fastest way to compare multiple variables?

Try this:
#!/usr/local/bin/perl -w use strict; my @list=("abcd123","abcd143","abcd123","abcd123"); $_=join("",@list); s/$list[0]//g; print "not equal\n" if ($_);

Replies are listed 'Best First'.
Re^3: Fastest way to compare multiple variables?
by owendelong (Initiate) on Feb 27, 2013 at 00:27 UTC
    The problem with that is that the code will produce an incorrect result in the case:

    my @list={"a","aaaa","aa","aaaaaaaa","a"};

    In the above (admittedly pathological) case, it would report all equal when this is not true.

      A comment correcting a code snippet that was posted 12 years ago.

      I love Perlmonks. ;-)

      Christopher Cashell

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://80825]
help
Chatterbox?
[Corion]: Yeah, you need bool to get a true value, and the rest to return the other value ;)
[choroba]: perl -wE '{package o; use Tie::Scalar; use parent -norequire => "Tie::StdScalar" ;sub FETCH { "x" x int rand 2}} tie my $x, "o" ; say $x for 1 .. 10'
[choroba]: for complete ness

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2017-07-27 13:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (414 votes). Check out past polls.