Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Function call inside regexp

by mickeyn (Priest)
on Mar 07, 2006 at 10:21 UTC ( #534873=note: print w/ replies, xml ) Need Help??


in reply to Function call inside regexp

Hi Luca,

use the /e modifier to evaluate the right-hand side of the RE.

$b =~ s/\:\:/File::Spec->rootdir()/e ;

Enjoy,
Mickey


Comment on Re: Function call inside regexp
Download Code
Re^2: Function call inside regexp
by nicoaimetti (Acolyte) on Mar 07, 2006 at 13:16 UTC
    The /e is the best option, I think.
    But just to mention it, there is another way to do it:
    $b =~ s/\:\:/${\(File::Spec->rootdir())}/;
    The trick is to use de-reference a refence to a value. You can put almost any expresion inside the ${\( )} and it will be well evaluated.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2015-07-07 12:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls