Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: require problems

by Shendal (Hermit)
on Sep 19, 2000 at 21:23 UTC ( #33131=note: print w/replies, xml ) Need Help??

in reply to require problems

From the require perldoc page:
The file must return TRUE as the last statement to indicate successful execution of any initialization code, so it's customary to end such a file with "1;" unless you're sure it'll return TRUE otherwise. But it's better just to put the "1;", in case you add more statements.
So, add this to the your file:
1; # return a one


Replies are listed 'Best First'.
RE: Re: require problems
by merlyn (Sage) on Sep 19, 2000 at 21:24 UTC
      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?

        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")

        Heheh, you're on to something...

        How about the age old paradox:

        "This statement is false.";
      my $true = "0 but true"; print "$true\n" if $true == 0;

      Or perhaps even more devilish:

      # return true 0 . 0;

      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"...


        Well, I fail to see how the string "0 but true" is any more special than "any true value will do".
        Your failure to see it doesn't mean it's not more special. See other posts in this thread.

        Hint: turn on warnings.

        -- Randal L. Schwartz, Perl hacker

      My current fave is:

      # 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)

RE: Re: require problems
by Kurious (Novice) on Sep 19, 2000 at 22:22 UTC
    Excellent! Thank you. That was the problem. Just, Kurious

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://33131]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2021-10-22 04:10 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (85 votes). Check out past polls.