#!/usr/bin/perl use strict; use constant { MIF_EXTENSION => "\.mif", TXT_EXTENSION => "\.txt" }; my $s0 = 'abcd.txt'; print "s0 =\t$s0\n"; $s0 =~ s/\.txt/\.mif/; print "s0 =\t$s0\n"; my $s1 = 'efgh.txt'; print "s1 =\t$s1\n"; $s1 =~ s/TXT_EXTENSION/MIF_EXTENSION/; print "s1 =\t$s1\n";
Scalar $s0 is substituted correctly, yet $s1 is not. What is required to get constants within substitutions to behave as desired? I was unsuccessful with specifying \Q...
Thanks.
In reply to use of constants in regex substitutions? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |