Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Given the code below:
#!/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.
Back to
Seekers of Perl Wisdom