Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
P is for Practical
 
PerlMonks  

Re4: Applying a RegEx in a variable

by Hofmator (Curate)
on Aug 10, 2001 at 12:37 UTC ( [id://103849]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Re: Re: Applying a RegEx in a variable
in thread Applying a RegEx in a variable

Well, you can always do it the qr// way (this is better anyway if you are using the same regex more than once). Or you can do it along these lines:

my $match; eval "\$String =~ $RegEx"; \$match = \$&"; print $match;
The code executed within the eval has access to the variables outside - again it works the same way as if the evaluated code was in a code block of its own.

-- Hofmator

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://103849]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.