in reply to RE: Re: require problems
in thread require problems

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?

Replies are listed 'Best First'.
RE: RE: RE: Re: require problems
by tye (Sage) on Sep 19, 2000 at 21:45 UTC

    But what is really special about "0 but true" is that it becomes 0 in a numeric context without a warning.

            - tye (but my friends call me "Tye")
      But what is really special about "0 but true" is that it becomes 0 in a numeric context without a warning.
      ding ding ding ding, that's what I was looking for!

      And now for trivia question 2, "why is this so?"

      -- Randal L. Schwartz, Perl hacker

        Is that a Perl feature or just because whatever the C function that turns strings into number is it likes the fact that it starts with a 0 and doesn't complain about the rest of the string? In which case "0 but" would be OK too?

      Ahh - but it wasn't *in* numeric context....