Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: scanning hash

by BrowserUk (Pope)
on Aug 01, 2004 at 11:16 UTC ( #379052=note: print w/ replies, xml ) Need Help??


in reply to scanning hash

use List Util qw[ reduce ]; print 'They\'re all the same!' if reduce{ $a && $a eq $b ? $a : () } values %hash;

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon


Comment on Re: scanning hash
Download Code
Re^2: scanning hash
by ysth (Canon) on Aug 01, 2004 at 11:26 UTC
    Very nice. But assumes that all values are true. It would be fairly easy to make it work with 0 or "" values, but not so easy to make it work with undef.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2015-07-01 20:25 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 (19 votes), past polls