Hello. I made a Perl script that allows users to supply the script with (a)an element name, (b)the element's symbol, or (c)the element's atomic number, and the script supplies the two missing fields. The script can be called with a list, i.e., perl prog.pl 1 2 3 4 5 6 That gets the first six elements; however, you can also call it like this to get a similar result: perl prog.pl 1..6. I include the script here in case any one else can find any uses for it.

($s,$n,$a)=split,$r={S,$s,N,$n,A,$a},$S{$r->{S}}=$r,$N{$r->{N}}=$r, $A{$r->{A}}=$r while <DATA>; $c = sub { local $_=pop;return if /^[san]$/; print"Name: $_\n"if s/^n//; print"Atomic Number: $_\n"if s/^a//; print"Symbol: $_\n"if s/^s//; }; for(@ARGV) { for(eval) { $_="n$A{$_}{N}:s$A{$_}{S}"if/\d+/; $_="n$S{$_}{N}:a$S{$_}{A}"if/^..?$/&&!/\d/; $_="s$N{$_}{S}:a$N{$_}{A}"if!/:/; split/:/;&$c($_[0]);&$c($_[1]); } } __DATA__ H Hydrogen 1 He Helium 2 <<rest of the elements go here>>

2001-06-14 Edit by Corion : Moved to Cool Uses For Perl (since Craft dosen't allow comments and would have required heavy reformatting)

Replies are listed 'Best First'.
Re: Periodic Table of the Elements
by John M. Dlugosz (Monsignor) on Jun 15, 2001 at 05:33 UTC
    I think the idea of the Table is interesting, but I don't find a program that looks it up to be terribly interesting. That is, it's just as simple to just look at the DATA table in a text file.

    Maybe make it more interesting by making it into a Quiz? It will prompt you for something and check your result. That would be good for studying, when learning the table in chemistry class.

    It doesn't handle the atomic weights. E.g. 1.00797 for H.

    It could take a molecule description, parse it, and return the weight. That could be an interesting calculator.

    —John

      Actually, I was going to make it into a quiz, and it was going to be for chemistry class(since I have to remember the elements, I'd figure I'd waste as much time as I could first).