RE: Re: require problems
by merlyn (Sage) on Sep 19, 2000 at 21:24 UTC
|
When I'm feeling particularly evil, I'll use:
2;
or
"any true value will do";
or even
"0 but true";
Trivia question: why is the string "0 but true" special, and what's special about it?
-- Randal L. Schwartz, Perl hacker | [reply] [d/l] [select] |
|
Well, it's true in Boolean context but 0 in numeric context. Looking through the docs on fcntl, it looks like it's useful for the Perl calls that are wrappers to C system calls.
For example, if fcntl returns -1 to signify failure, Perl will massage that into undef. If it returns 0, Perl will use "0 but true" -- which means you can use it either numerically (C-style, expecting 0 to correspond to success) or Booleanifically (Perl-style, expecting 'true' to mean success).
Close enough?
| [reply] |
|
| [reply] |
|
|
|
|
|
I think that particularly evil would be:
"false";
Cheers,
Shendal
| [reply] [d/l] |
|
"This statement is false.";
| [reply] [d/l] |
|
my $true = "0 but true";
print "$true\n" if $true == 0;
| [reply] |
|
# return true
0 . 0;
| [reply] [d/l] |
|
I'd actually write that as:
0 . 0; # sometimes, whitespace DOES matter
{grin}
-- Randal L. Schwartz, Perl hacker | [reply] [d/l] |
|
# grr...
"Why should version 5.6 make me do this in a module?"
Of course I like the capital letter "O"; too =)
--
$you = new YOU;
honk() if $you->love(perl) | [reply] [d/l] |
|
Well, I fail to see how the string "0 but true" is any
more special than "any true value will do".
They're both simply strings that interpolate in a boolean context to true
how about:
0 . "true";
for something ever so slightly more "evil"...
(c8=
| [reply] [d/l] |
|
| [reply] |
RE: Re: require problems
by Kurious (Novice) on Sep 19, 2000 at 22:22 UTC
|
Excellent! Thank you. That was the problem.
Just,
Kurious | [reply] |