use constant {
MIF_EXTENSION => "\.mif",
TXT_EXTENSION => "\.txt"
};
This is not doing what you want it to. The backslash is interpreted when perl parses the double-quoted string, so the values end up being '.mif' and '.tif' (since \. has no special meaning in a double-quoted string, as does, say \n). Your regexp will then match any character followed by txt. You need to either:
- Put the extensions in single-quoted strings, so the backslash is preserved.
- Put \Q and \E in your substitution to disable pattern metacharacters (see perlre for more info if you don't know what that means). Example:
$s1 =~ s/\Q${\TXT_EXTENSION}\E/MIF_EXTENSION/e;
I personally recommend #2, since you want to match literal text, without metacharacters, and that's what \Q is for.
Also, you should follow Zaxo's advice, and not dmitri's, since one will work, and one won't (you guess which is which).
--
3dan
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.