Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Add Hash Key Based on Matching Another Key

by Ratazong (Monsignor)
on Jul 28, 2010 at 14:50 UTC ( [id://851729]=note: print w/replies, xml ) Need Help??


in reply to Add Hash Key Based on Matching Another Key

What about using a nested hash instead of the array? That will save you the lookup-loop when updating an element...

my %data; # btw.: never call your structure "data" in "real progra +ms" ;-) my $mac = "11:22:33:55:66:77"; $data{$mac}{ap_name} = "AP one"; $data{$mac}{ap_model} = "1131"; my $mac2 = "00:00:00:00:00:00"; if (exists($data{$mac2}) { $data{$mac2}{serial} = "FTX12345"; }

HTH, Rata

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2025-07-13 20:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.