($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 | |
by dimmesdale (Friar) on Jun 15, 2001 at 19:41 UTC |