Ask your own question, for FREE!
Computer Science 11 Online
thomaster (thomaster):

Anyone with knowledge of perl here?

thomaster (thomaster):

Oke so I'm new to perl, need it for my bioinformatics minor. Just playing around a little and I stumbled upon something that's probably very easy, but I can't get it to work. I have a hash: my %symbol=( "1"=>"H", "2"=>"He", "3"=>"Li", "4"=>"Be", "5"=>"B", "6"=>"C", "7"=>"N", "8"=>"O", "9"=>"F", "10"=>"Ne", "11"=>"Na", "12"=>"Mg", "13"=>"Al", "14"=>"Si", "15"=>"P", "16"=>"S", "17"=>"Cl", "18"=>"Ar", "19"=>"K", "20"=>"Ca", ); the first number is an atomic number, the value is the corresponding atom abbreviation. atomic number 1 is hydrogen which is H what I need is to enter a value, and the program should return the element symbol so if I enter 15, it should return P No idea how to do this xD

thomaster (thomaster):

my $atomicNumber=<STDIN>;chomp($atomicNumber);

thomaster (thomaster):

Another way is to put it in an array instead of a hash, can I return the nth value in an array? That way I only have to put them in order in a 1-dimensional table. The 18th value in the array would be Ar. How to I get the 18th value?

thomaster (thomaster):

@e.mccormick

thomaster (thomaster):

Do you know this? @Opcode

OpenStudy (e.mccormick):

I only learned enough Perl to modify some scripts other made. But I googled up perl data types and found this: http://www.oreillynet.com/pub/a/perl/excerpts/9780596000271/data-structures.html It looks like you have some good options there.

thomaster (thomaster):

oh wow thanks, first example already does the trick :)

Elsa213 (elsa213):

1st I c a thanks from you thomaster :D

thomaster (thomaster):

haha 2 months later this question would have been easy peasy :P been working on much more complex problems since

Elsa213 (elsa213):

pffft i dun believe dat ;p

OpenStudy (e.mccormick):

All it takes is familiarity with the specifics of a language and knowledge of programming theory. After 2 months, I bet his familiarity is a lot better.

jaynator495 (jaynator495):

@perl how about you help here? :P

OpenStudy (e.mccormick):

She has perls of wisdom, not perls of code.

jaynator495 (jaynator495):

LOL

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
HeyItsAlicia: Why was questioncove not working??
2 hours ago 2 Replies 1 Medal
Countless7Echos: Ah trying out the whole T.V girl drawing :p (I love drawing eyes)
12 hours ago 14 Replies 6 Medals
kaelynw: starting to draw a hand
2 days ago 17 Replies 2 Medals
Twaylor: Rate it :D (Took 2 days)
6 days ago 7 Replies 0 Medals
XShawtyX: Art, Short Writing Assignment: Imagining Landscapes
2 days ago 9 Replies 1 Medal
XShawtyX: Chemistry, Help ud83dude4fud83cudffe
1 week ago 13 Replies 1 Medal
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!