Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: help with hashes

by gaal (Parson)
on Mar 15, 2005 at 11:56 UTC ( [id://439597]=note: print w/replies, xml ) Need Help??


in reply to help with hashes

To subscript a hash, say $aminoacids{ $the_key }. (In your case, the keys are numeric so you may as well be using an array?)

This interpolates in a string, too, so you can say:

print "$aminoacids{$i} $aminoacids{$j} $aminoacids{$k}\n";

Though you can use the more idiomatic hash slice and select several things at once.

print join " ", @aminoacids{$i, $j, $k}; # note the '@'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-28 16:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found