Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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 stylesheet.pl file:
1; # return a one

Cheers,
Shendal


Comment on Re: require problems
Select or Download Code
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")

      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=

        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

        Heheh, you're on to something...

        How about the age old paradox:

        "This statement is false.";

      Or perhaps even more devilish:

      # return true 0 . 0;
      my $true = "0 but true"; print "$true\n" if $true == 0;

      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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-12-28 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls