Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Parens mess up regex substitute

by Crackers2 (Parson)
on Jan 26, 2012 at 16:14 UTC ( #950154=note: print w/replies, xml ) Need Help??


in reply to Parens mess up regex substitute

While all of the above answers are correct, I think they may be slightly missing the point of your question. What I understand you're asking is: "Why do the parens in $str do not screw up

(my $name = $str) =~ s{.*/}{}; # basename

but do screw up

(my $path = $str) =~ s{$name}{};

?"

And the answer to that is: they don't. It's not the parens in $str that are the problem in the second substitution, it's the parens in $name

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950154]
help
Chatterbox?
[marto]: how many lawyers does it take to turn on a lightbulb?
[Eily]: make them wear gloves because if they leave fingerprints they have the right to ask you to dispose of the bulb at any time
[Corion]: marto: Heh - on the other hand, that's quite good IMO, as home automation information shouldn't leave the home network anyway...
[Corion]: Also, Twitter now seems to work with JS disabled... It asks me if I want to go to the Twitter legacy version. Progress?!

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2018-05-25 12:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?