Is this the kind of output you're looking for?
perl -ne"print $1,'-',$2||1,' 'while /([A-Z][a-z]*)(\d+)?/g;print qq[\
+n]" CON
CH4N2O
C-1 H-4 N-2 O-1
C9H12N2O6
C-9 H-12 N-2 O-6
C5H11NO2
C-5 H-11 N-1 O-2
C5H4N4O2
C-5 H-4 N-4 O-2
C10H11N4O9P
C-10 H-11 N-4 O-9 P-1
C10H12N4O6
C-10 H-12 N-4 O-6
C5H10O5
C-5 H-10 O-5
C5H12O5
C-5 H-12 O-5
C5H10O5
C-5 H-10 O-5
C27H44O
C-27 H-44 O-1
C1694H2993O101
C-1694 H-2993 O-101
^Z
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.