Monks - I have a text file that I'm trying to open, and
reformat each line. The file contents looks like this:
1996.40637
1996.41064
1996.41199
1996.41467
1996.41882
I want to write a regex that takes one of these dates,
removes the decimal, and removes the first two #'s, i.e.
from 1996.41064 to 9641064
I can get the pattern right, but not the replacement.
Can you help fix the statement to
$new = s/\d+.\d/replacement/g;
get the replacement string to work? I tried using substr on
the value, but this didn't work, i.e.
$new = s/\.//g;
$new = substr($new, 2);
Thanks
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.