Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: question on Hashes

by markkawika (Monk)
on Sep 01, 2009 at 23:01 UTC ( [id://792753]=note: print w/replies, xml ) Need Help??


in reply to question on Hashes

A hash cannot have two keys.

However, you can combine values together to create a single key:

$var{$firstname . $middlename} = ...

Or you can have a multi-dimensional hash:

$var{$firstname}{$middlename} = ...

But neither of those addresses the issue of collisions; you already stated that many records have the same first name, but can you guarantee that firstname + middlename is unique? Are you sure?

Typically in databases of the sort you're describing, the hash key is forced to be unique. Something like an "id number" or something. Then you can store data about the person without worrying about hash collisions.

Really, the question is, what do you want to do with the data that you have? Why are you storing it, and what will you do with it after you store it?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-09-09 06:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.