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

Re: short method to print age.

by Roy Johnson (Monsignor)
on Mar 05, 2009 at 19:20 UTC ( #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.


Comment on Re: short method to print age.
Download Code
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
Node Status?
node history
Node Type: note [id://748637]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2015-07-05 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls