Re: subroutine helpby space_monk (Chaplain)
|on Nov 29, 2012 at 07:37 UTC||Need Help??|
I'm sure it's been done before in the other answers, and maybe even more efficiently, but this is what I think you're trying to get to:
Feel free to modify for your purposes and correct naming,read atomic weights from a file etc.
Output from above program:
Updated to reflect the fact that some transuranic elements have 3 letter identifiers, not just two. :-)
Also updated to reflect suggestions by Kenosis and others below....
Whilst adequate for the indicated input, the method of parsing and atomic weight calculation is a little lightweight and basic, and doesn't handle more complex molecules, so consider using Chemistry::Mol or a similar package if you want to get round the flaws that have been indicated below....
A Monk aims to give answers to those who have none, and to learn from those who know more.