Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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 ;


Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://534873]
[Corion]: holli: If you are in Frankfurt, I can recommend the Ubahnkontrollöre - they have two gigs, one on the 28th Dec., the next in May 2018
[Corion]: They don't do new material anymore, but the old stuff is good enough IMO :)
[holli]: hessenrap...
[holli]: love it :)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-11-18 19:26 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (277 votes). Check out past polls.