Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Dualvars besides $!

by davido (Cardinal)
on Jan 27, 2014 at 17:41 UTC ( [id://1072257]=note: print w/replies, xml ) Need Help??


in reply to Dualvars besides $!

I think you are misinterpreting the results of your test. (No, I was misunderstanding what point was being made. ;)

Scalar::Util::isdual returns a true value if the variable being tested is a dualvar. Your test indicates that isdual is returning 1 when tested against $!, which is a true value, indicating that $! is a dualvar.

Update: A list of "dualvar" special variables, as I find them.

  • $( The documentation eludes to this; it may contain a space-delimited list (a string), but you can only assign a number to it.
  • $) The documentation is similar on this one, and it too is a dualvar.
  • $^E The POD says "Caveats mentioned in the description of $! generally apply to $^E , also."

Also, since $_ implicitly topicalizes a foreach loop, and since it's an alias to an iteration's topic, it can be made to appear to be a dualvar:

for ( $! ) { print Scalar::Util::isdual($_), "\n"; }

...outputs '1', because in this case $_ is an alias to a dualvar. So we can add to the list:

  • Any variable that aliases a dualvar becomes a dualvar while the alias is in effect (consider foreach ( $! ) { # $_ is a dualvar here })

Dave

Replies are listed 'Best First'.
Re^2: Dualvars besides $!
by szabgab (Priest) on Jan 27, 2014 at 18:50 UTC
    That's my point. dualvar indicates that $! is indeed a dualvar but the documentation of Scalar::Util say $! is not a dualvar. Or did I misunderstand what the documentation claims?

      Oh, I see what you're saying. It's probably a bug in the documentation for isdual, though relying on how a feature is implemented internally always carries risks.


      Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found