First, there is no need to backslash (escape) the colon. It's not a metacharacter. However, that isn't your problem.
When I try the simple code:
use strict;
use warnings;
while (<DATA>) {
s/://g;
print $_;
}
__DATA__
9:23:00
02:23:34
I find that colons are indeed removed. So the problem is probably related to how you're handling the file IO.
Unless you're using the -i command line option, you can't edit the file in place. You need to open the original file for input, open a temporary file for output, read the orig, get rid of the colons, write the results to the temp file, and then move the temp file to replace the orig.
That ought to do the trick.
Of course if you're just trying to remove colons from times, and preserve them elsewhere, this solution is too aggressive. But your original question didn't really specify.
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein
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.