Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Perl file rename

by afoken (Chancellor)
on Jun 04, 2015 at 08:05 UTC ( [id://1129029]=note: print w/replies, xml ) Need Help??


in reply to Perl file rename

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

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1129029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found