Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: short method to print age.

by Roy Johnson (Monsignor)
on Mar 05, 2009 at 19:20 UTC ( [id://748637]=note: print w/replies, xml ) Need Help??


in reply to short method to print age.

This mimics what you do.
print "Alex children are \n\n " , join("\nand ", map $_->{age}, reverse @{$alex{children}}) , "years old\n";
Obviously the reverse isn't necessary unless you really want it.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: short method to print age.
by zouz (Initiate) on Mar 05, 2009 at 19:42 UTC
    Thank you all for the answers you guys offered. i think i will end up using this code.
    #!/usr/bin/perl use warnings; %alex = ( 'name' => 'Alex', 'age' => '45'); %john = ( 'name' => 'John', 'age' => '20'); %chaddy = ( 'name' => 'Chady', 'age' => '16'); @children = (\%john, \%chaddy); $alex{'children'} = \@children; print "Alex children are \n " , join("\nand ", map $_->{age}, reverse @{$alex{children}}) , "\tyears old\n"; print "Alex is $alex{age} himself\n";
    instead of the one i mentioned above. much easier to understand i guess,thx Roy and thank you all once again.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-18 19:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found