Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: 1 but false

by danger (Priest)
on Jan 08, 2002 at 01:23 UTC ( [id://136953]=note: print w/replies, xml ) Need Help??


in reply to 1 but false

Another way is to use a dualvar() (from Scalar::Util) for such a purpose:

use Scalar::Util qw/dualvar/; my $x = dualvar(1,"0"); $y = $x + 41; print "$y\n"; # 42 print "Str \$x: $x\n"; print "Num \$x: ", $x + 0, "\n"; if($x + 0){print "\$x + 0 is true\n"} unless($x){print "\$x is false\n"} __END__ prints: 42 Str $x: 0 Num $x: 1 $x + 0 is true $x is false

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://136953]
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: (2)
As of 2024-04-24 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found