Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Why no warnings for 1 in void context?

by davido (Archbishop)
on Jul 16, 2005 at 16:25 UTC ( #475471=note: print w/ replies, xml ) Need Help??

in reply to Why no warnings for 1 in void context?

It is so that the convention of ending a module with 1; won't trigger a warning. Modules must return truth, and it's common practice to put a 1; on the last line to satisfy this criteria.

See perlmod for supporting documentation.


Comment on Re: Why no warnings for 1 in void context?
Select or Download Code
Replies are listed 'Best First'.
Re^2: Why no warnings for 1 in void context?
by samtregar (Abbot) on Jul 16, 2005 at 16:54 UTC
    The final line of a required module isn't in void context - it's the return value of the require. Try putting something else there and you'll see there's no warning. I worked with a guy who put (unfortunately copyrighted) poetry in a string at the end of his modules.


      It is actually always in scalar context. I learned this while trying to be a wise ass with Devel::FIXME.

      zz zZ Z Z #!perl
      Yeah. I like to end modules with 42;

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2015-10-07 05:12 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (170 votes), past polls