Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: When hashes aren't enough

by fletcher_the_dog (Friar)
on May 25, 2004 at 15:51 UTC ( [id://356273]=note: print w/replies, xml ) Need Help??


in reply to When hashes aren't enough

if you don't want to do OO than building a hash of hashes could be pretty easy to work with. You could do something like this:
my %vehicles = ( Car=>{ Wheels=>4, Doors=>4, Color=>"Blue", }, Bike=>{ Wheels=>2, Color=>"Red", } ); # work with the attributes while (my($vehicle,$attributes)=each(%vehicles)){ print "Let me tell you about a $vehicle\n"; if(my $color = $attributes->{Color}){ print "A $vehicle is $color\n"; } if(my $wheels = $attributes->{Wheels}){ print "A $vehicle has $wheels wheels\n"; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-25 13:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found