This "False" value is basically the same as
use Scalar::Util qw/dualvar/;
dualvar(0, '');
Which stems from the curious fact that a Perl scalar internally has a slot for both a numeric and a string value. By explicitly providing a numeric value, you don't get a warning when used as a number:
$ perl -wE 'say 1 + ""'
Argument "" isn't numeric in addition (+) at -e line 1.
1
$ perl -MScalar::Util=dualvar -wE 'say dualvar(0, "") + 1'
1
Note that when abused, these dualvars can be very confusing:
$ perl -MScalar::Util=dualvar -E 'my $x = dualvar(42, "23"); say $x; s
+ay $x + 1'
23
43
Devel::Peek shows that the False value is a wee bit more special than that:
perl -MDevel::Peek -MScalar::Util=dualvar -e 'Dump !1; Dump dualvar(0,
+ "")'
SV = PVNV(0x254ff70) at 0x7409c0
REFCNT = 2147483647
FLAGS = (IOK,NOK,POK,READONLY,pIOK,pNOK,pPOK)
IV = 0
NV = 0
PV = 0x254ff50 ""\0
CUR = 0
LEN = 8
SV = PVNV(0x2550d90) at 0x2551220
REFCNT = 1
FLAGS = (TEMP,IOK,POK,pIOK,pPOK)
IV = 0
NV = 0
PV = 0x255f610 ""\0
CUR = 0
LEN = 8
So it's not only a dualvar, but it's also readonly, and has a very high refcount - it's basically a singleton.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.