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

Re: Why no warnings for 1 in void context?

by dave_the_m (Parson)
on Jul 16, 2005 at 16:06 UTC ( #475468=note: print w/ replies, xml ) Need Help??


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

It's so that code like the following works without warnings:

1 while ....
NB - the 1 in a require isn't evaluated in a void context, so it wouldn't generate a warning anyway.

Dave.


Comment on Re: Why no warnings for 1 in void context?
Download Code
Replies are listed 'Best First'.
Re^2: Why no warnings for 1 in void context?
by tlm (Prior) on Jul 16, 2005 at 16:32 UTC

    1 while ....

    That makes sense. Thanks.

    NB - the 1 in a require isn't evaluated in a void context...

    It is if, as I wrote, you syntax-check I did not write about the normal situation in which a module is require-ed; I referred to the case when one syntax-checks the module's file with perl -wc, e.g.:

    % echo 1 > Foo.pm % perl -wc Foo.pm Foo.pm syntax OK % echo 2 > Foo.pm % perl -wc Foo.pm Useless use of a constant in void context at Foo.pm line 1. Foo.pm syntax OK
    (Hey, I did say it was a tortured rationale!)

    But yes, normally, when a module is require'd the 1 (or whatever) is not evaluated in a void context.

    Update: I fixed the wording, in response to ikegami's reply. The question of whether doing a syntax check on a module with perl -wc somehow turns it into a script is too metaphysical even for me.

    the lowliest monk

      It is if, as I wrote, you syntax-check the module's file with perl -wc, e.g.:

      Then it's no longer a module, it's just a script. The parent poster did say "in a require".

      >echo 2 > Foo.pm >perl -we "use Foo;" >perl -cwe "use Foo;" -e syntax OK

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2015-07-08 05:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls