Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: functions inside patterns

by danger (Priest)
on Dec 20, 2001 at 10:48 UTC ( [id://133419]=note: print w/replies, xml ) Need Help??


in reply to functions inside patterns

The pattern is given double-quotish interpolation (unless single quotes are the delimiter), so you can interpolate functions in a pattern the same as you would in a double quoted string --- ie, as per this faq. For example:

$_ = 'this is foo here'; sub foo {return 'foo'} print "Yup\n" if m/@{[foo()]}/; print "Yup\n" if m/${\(foo())}/;

However, while this answers your question (I think), it isn't necessarily the best thing to be doing (and be careful with context).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-25 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found