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

Re^3: how to declare a local *subname=sub{}?

by LanX (Saint)
on Oct 30, 2016 at 23:05 UTC ( [id://1174975]=note: print w/replies, xml ) Need Help??


in reply to Re^2: how to declare a local *subname=sub{}?
in thread how to declare a local *subname=sub{}?

1) because local restores the (here undef) value of the code slot of *asub at the end of the scope, which is reached before stuff() is called.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^4: how to declare a local *subname=sub{}?
by perl-diddler (Chaplain) on Oct 31, 2016 at 11:57 UTC
    Now I think I see one source of your frustration.

    The call to "stuff" is within the scope of the "local *asub", which has a value assigned to "asub" that is also within the same scope as "sub stuff".

    i.e. the "undef" value preserved outside of the scope of the "local" ends past "sub stuff".

    That's why it is a curiosity. I couldn't see (and still don't) why adding the "local" statement (who's scope includes "sub stuff") should make a difference.

      > I couldn't see (and still don't) why adding the "local" statement (who's scope includes "sub stuff") should make a difference.

      Because you still haven't read any of the doc links provided.

      local is a totally different beast compared to my and our .

      > Now I think I see one source of your frustration.

      well "frustration" is exaggerated ... I'll just stop talking to you until you do your homework. :-)

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 06:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found