Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^3: Learning about hashes

by DamianKaelGreen (Acolyte)
on Oct 22, 2009 at 16:58 UTC ( #802771=note: print w/ replies, xml ) Need Help??

in reply to Re^2: Learning about hashes
in thread Learning about hashes

OK, I think I see what you are trying to do, but a hash may not be what you want. A list might be better for your needs. List ex:

use List::MoreUtils qw(any); #instead of using: # "if (grep( m/whatever/, @list)){}" #use: "if (any { m/whatever/} @list){}" #this exits on the first occurrence. if (!any {m/^\Q$record[3]\E$} @esList){ #the \Q\E guarantees that the value held in the $record[3] #is not interpreted as a regular expression push (@esList = $record[3]); } ### @esList is now a unique list of the values you want...
But if you really want to use a hash, this is how you might do it:
my %esList = (); $esList{$record[3]) = 1; ### then to recall all the found records: foreach my $result {sort(keys(%esList))){ print "found record: $result \n"; }
Also, if you're interested, I started a discussion recently about how to best implement multidimensional hashes, they have some unique characterictics that you might not expect when trying to extending principals of a one dimensional hash. But there are some very good references listed there. It can be found at: Best Multidimensional Hash Practices? Good luck...

Comment on Re^3: Learning about hashes
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2015-11-29 05:36 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (747 votes), past polls