in reply to Re: Recursive capture of a variable number of elements using regexp
in thread Recursive capture of a variable number of elements using regexp

Or without the  while loop (the file  chem.data holds the data specified in the OP):
>perl -wMstrict -ne "print qq{$_\t}, join(qq{\t}, /([A-Z][a-z]?(\d*))(?=.*(\n?))/g); " chem.data CH4N2O C H4 4 N2 2 O C9H12N2O6 C9 9 H12 12 N2 2 O6 6 C5H11NO2 C5 5 H11 11 N O2 2 C5H4N4O2 C5 5 H4 4 N4 4 O2 2 C10H11N4O9P C10 10 H11 11 N4 4 O9 9 P C10H12N4O6 C10 10 H12 12 N4 4 O6 6 C5H10O5 C5 5 H10 10 O5 5 C5H12O5 C5 5 H12 12 O5 5 C5H10O5 C5 5 H10 10 O5 5 C27H44O C27 27 H44 44 O C1694H2993O101 C1694 1694 H2993 2993 O101 101
Note, however, that this approach: