Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
No such thing as a small change
 
PerlMonks  

Re: Inspecting the name of a variable

by philiprbrenan (Monk)
on Sep 01, 2012 at 19:49 UTC ( #991188=note: print w/ replies, xml ) Need Help??


in reply to Inspecting the name of a variable

From the manual entry for 'for':

Foreach Loops

The foreach loop iterates over a normal list value and sets the variable VAR to be each element of the list in turn. If the variable is preceded with the keyword my, then it is lexically scoped, and is therefore visible only within the loop. Otherwise, the variable is implicitly local to the loop and regains its former value upon exiting the loop. If the variable was previously declared with my, it uses that variable instead of the global one, but it's still localized to the loop. This implicit localization occurs only in a foreach loop


Comment on Re: Inspecting the name of a variable
Re^2: Inspecting the name of a variable
by LanX (Abbot) on Sep 01, 2012 at 20:18 UTC
    Well ... RTFM doesn't explain anything. =)

    localized variables are propagated into any called subs.

    apparently PadWalker is missing a pad to investigate or should extend it's documentation.

    UPDATE: ... well only if aliases have a pad...

    UPDATE: yes it's because of the aliasing:

    our $orig=666; for our $x (42,$orig) { say $bar,our_name($bar); say $x,our_name($x); }

    10$bar 42 10$bar 666$orig

    Cheers Rolf

      Hello

      I found Data::Dumper::Names with this thread . In this manual of Data::Dumper::Names, there is "Unknown Variables" section.

      "Unknown Variables" section seems to me having some relation with your case... not printing name "$x".

      update:
      Sorry if I am looking into wrong direction.
        Thats where I started, but if you look into Ovid's code you will see that he's only inspecting lexical variables.

        Cheers Rolf

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (18)
As of 2014-04-18 19:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (471 votes), past polls