Re: Perl Peeves
- From: Eric Pozharski <whynot@xxxxxxxxxxxxxx>
- Date: Thu, 29 Jan 2009 10:45:57 +0200
On 2009-01-28, Peter J. Holzer <hjp-usenet2@xxxxxx> wrote:
On 2009-01-27 09:08, Eric Pozharski <whynot@xxxxxxxxxxxxxx> wrote:
On 2009-01-27, Tim McDaniel <tmcd@xxxxxxxxx> wrote:
(5) That "special false". I was going nuts trying to figure out what
was different between
[ '' in string context, 0 in numeric context ]
That special false is evaluated to blah-blah-blah *immediately* since
the context is known at compile time (am I right?).
No. Consider:
#!/usr/bin/perl
use warnings;
use strict;
my $bool = (1 < 0);
if (rand() < 0.5) {
print "<$bool>\n";
} else {
print 0 + $bool, "\n";
}
No, special false is sticky. That explains better though, I think.
perl -wle '
my($nil, $empty) = (0, q||);
print qq|<$nil> <$empty>|;
print 0 + $nil;
print 0 + $empty;
'
<0> <>
0
Argument "" isn't numeric in addition (+) at -e line 5.
0
p.s. IOW -- me wrongs.
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
.
- References:
- Perl Peeves
- From: Tim McDaniel
- Re: Perl Peeves
- From: Eric Pozharski
- Re: Perl Peeves
- From: Peter J. Holzer
- Perl Peeves
- Prev by Date: Re: Regex for <option> ... </option>
- Next by Date: Want to extract the proxy list by using regexp.
- Previous by thread: Re: Perl Peeves
- Next by thread: Re: Perl Peeves
- Index(es):
Relevant Pages
|