Binary package “libchemistry-formula-perl” in ubuntu trusty

enumerate elements in a chemical formula

 This module provides a function which parses a string containing a
 chemical formula and returns the number of each element in the string.
 It can handle nested parentheses and square brackets and correctly
 computes stoichiometry given numbers outside the (possibly nested)
 parentheses.