Don Coyote has asked for the wisdom of the Perl Monks concerning the following question:
hacking on %main::, I printed out keys and values. The $=>*main::$ looked an ideal candidate to test out my uninformed theories about local on. When I asked scalar($main::{$}) though the string of the value of the key was returned rather than a value as I was expecting.
scalar($main::{$}), or scalar($main::{q<$>}) from cli, returned the string *main::$ which is the hash value for *main::$ and not a numeric value as I was expecting.
Is this something to do with the implicit recursiveness of the main hash?
Update: oh its scalar() behaviour. returns the scalar if it is a scalar else returns the number of items if its a list being brought into scalar context. Of course!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: scalar(*main::{VALUE}) appears to return a string rather than a value?
by Anonymous Monk on Nov 11, 2012 at 14:05 UTC | |
by Anonymous Monk on Nov 11, 2012 at 14:12 UTC | |
by Don Coyote (Hermit) on Nov 11, 2012 at 16:51 UTC | |
by Don Coyote (Hermit) on Nov 11, 2012 at 14:16 UTC |