http://www.perlmonks.org?node_id=1079319


in reply to Re^3: How to avoid an alphabet and integer next to it in a string?
in thread How to avoid an alphabet and integer next to it in a string?

$molform =~ s/[^a-zA-G0-9]//g;

Just eliminate the Hydrogen:

$molform =~ s/H\d*//g;