Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Keyed matrix

by choroba (Cardinal)
on Sep 03, 2012 at 12:17 UTC ( [id://991411]=note: print w/replies, xml ) Need Help??


in reply to Keyed matrix

What you defined is not what you need:
%chores = (Monday => "dishes", 1 => "Tuesday", vacuum => "2", Wednesday => "garbage", "3");
Under warnings, you would have got
Odd number of elements in hash assignment
To solve your problem, you need a hash of arrays:
my %chores = (Monday => ["dishes" , "1"], Tuesday => ["vacuum" , "2"], Wednesday => ["garbage" , "3"]); my $value = join ' ', @{ $chores{Wednesday} }; print "$value\n";
See Perl Data Structures Cookbook and Perl references and nested data structures for details.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found