in reply to
Re^7: 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?
Think about it. How does that help (read again what output I asked for)? When you're trying to determine input and output to something...just print the something...
my $molform = <STDIN>;
print "Molform before: [$molform]\n";
s/\s+$//, s/H(?![a-z])\d*//g for $molform;
print "Molform after: [$molform]\n";
may have nailed the problem...you need to learn how to provide useful debugging information.