my $pattern = qr/$test/; my $pattern1 = qr/$test1/; # ... $new =~ s/$pattern/$pattern1/;
I think you have another problem here: The right-hand side of s/// (REPLACEMENT in s/PATTERN/REPLACEMENT/) is not a regular expression, but a string. See Regexp Quote Like Operators. Your use of qr// makes a regular expression from the second argument, then stringifies it. That will very likely give you an unexpected result:
>perl -e '$x="abc"; $p=qr/b/; $r=qr/X/; $x=~s/$p/$r/; print $x' a(?^:X)c >
Alexander
In reply to Re: Perl file rename
by afoken
in thread Perl file rename
by keltan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |