in reply to Regular Expressions and atomic weights

Chemistry::Mol seems to do all that, including parse the formula.

$ perl -MChemistry::File::Formula -e'my $mol = Chemistry::Mol->parse(" +Pb(CO3)2",format=>"formula");print $mol->mass,$/' 327.2178 $

After Compline,
Zaxo