Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

(dkubb) Re: (5) Fastest way to compare multiple variables?

by dkubb (Deacon)
on May 18, 2001 at 12:22 UTC ( #81448=note: print w/ replies, xml ) Need Help??


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

I too couldn't resist. A single walk through the hash's keys is the fastest way I could think of doing this:

sub dkubb_compare { my $data = shift; my $first = @{$data{scalar each %$data}}; while(my $key = scalar each %$data) { return 0 unless $first == @{$data{$key}}; } return 1; }

IMHO, it's a little too obscure to be used in production code, but I think it still is a neat idiom.


Comment on (dkubb) Re: (5) Fastest way to compare multiple variables?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2015-07-06 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls