Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Accessing a scalar value in another subroutine?

by LanX (Bishop)
on Sep 23, 2012 at 20:03 UTC ( #995242=note: print w/replies, xml ) Need Help??


in reply to Re: Accessing a scalar value in another subroutine?
in thread Accessing a scalar value in another subroutine?

I doubt this is a good idea $docstring is only initialized after method1 is called for the first time.

So you won't be able to inspect the docstring in advance.

But if that's OK for you you might wanna try PadWalker::peek_sub.

UPDATE:

Nope doesn't help, lexical are reset to undef after the function-scope is left.

DB<135> sub tst { my $doc="bla" } => 0 DB<136> PadWalker::peek_sub(\&tst) => { "\$doc" => \undef } DB<137> tst() => "bla" DB<138> PadWalker::peek_sub(\&tst) => { "\$doc" => \undef }

Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995242]
help
Chatterbox?
[karlgoethebier]: My perltidy adds a semicolon after .... How can i avoid this?
[LanX]: ellipse aka ... aka yadda yadda is a new command
[LanX]: sopw!

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2017-11-18 18:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?