Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Passing regex to a subroutine

by kcott (Abbot)
on Oct 13, 2012 at 10:43 UTC ( #998838=note: print w/ replies, xml ) Need Help??


in reply to Passing regex to a subroutine

G'day ll001,

I see that ++aitap has identified your problem.

Seeing your usage of $regexStr, I was wondering if you were aware that qr{...} does not return a string per se. It actually returns a Regexp object. When stringified, this is overloaded to produce something you may not have expected.

$ perl -e 'my $regexStr = qr{[0-9]+}; print "$regexStr\n"; print ref($regexStr), "\n"; ' (?^:[0-9]+) Regexp

See perlop - Regexp Quote-Like Operators for details.

-- Ken


Comment on Re: Passing regex to a subroutine
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2015-07-03 06:16 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 (48 votes), past polls