Novice perl user here asking for a bit of help. I have a bunch of data that was badly formatted to contain strings like this:
Washington, D.c.
and
New York, N. y.
I'm trying to process the data to correct these instances, ie change 'D.c.' to 'D.C.' etc.
This is what I tried:
$this_term = 'Washington, D.c.';
$this_term =~ s/\.[a-z]/\.[A-Z]/g;
print "$this_term";
I get this:
'Washington, D.A-Z.' instead of the desired 'Washington, D.C.'
Can someone show me what I'm doing wrong? I've spent a stupid amount of time on this, and I know the solution must be simple, but I can't find it.
Thanks gang.
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.