Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Named captures or positional variables

by RonW (Parson)
on Dec 11, 2014 at 00:34 UTC ( [id://1109994]=note: print w/replies, xml ) Need Help??


in reply to Re: Named captures or positional variables
in thread Named captures or positional variables

Maybe something like use revar name => "regex";

or use revar '$name' => "regex";

(Which are similar to use constant or use vars)

Note: I suspect this would create "our" variables. Is it possible for a pragma to create "my" variables in the use-ing package?

Replies are listed 'Best First'.
Re^3: Named captures or positional variables
by LanX (Saint) on Dec 11, 2014 at 01:18 UTC
    > Is it possible for a pragma to create "my" variables in the use-ing package?

    If lexical variables are already declared in the calling package, you can change their value, e.g. with PadWalker.

    Otherwise it wouldn't compile under strict if you try to use them.

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

      Declaration can be worked around using parser hacks. That's what Object::Util does. It declares and populates lexical variables for the caller. (Though it falls back to package variables if it's unable to do the parser hacking stuff.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-26 02:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found