Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: scanning hash

by ysth (Canon)
on Aug 01, 2004 at 11:46 UTC ( #379056=note: print w/ replies, xml ) Need Help??


in reply to scanning hash

Here's a scalable, undef-friendly solution, just for kicks:

my $multiple_values; my ($k,$v); use Data::Dumper; $Data::Dumper::Useqq = 1; while (defined($k = each %hash)) { if ($v) { ++$multiple_values, last if Dumper($hash{$k}) ne $v; } else { $v = Dumper($hash{$k}) } }
It does distinguish between strings and numbers that eq would say were the same, though.


Comment on Re: scanning hash
Download Code
Re^2: scanning hash
by Aristotle (Chancellor) on Aug 01, 2004 at 15:05 UTC

    That is nice in the spirit of TMTOWTDI, but it's overengineered and inefficient. defined is a perfectly sufficient vehicle to write code that handles undef vs empty string correctly.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2015-07-03 18:11 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 (55 votes), past polls