in reply to Re^4: expression which does nothing
in thread expression which does nothing
Note that no true value at the end of a module, whatever you choose, causes a complaint under normal cicrumstances, actually because a module is loaded in scalar context.
As a test: I saved this little module as "Temp.pm" in the current directory:
This command line makes it work without warning:# Temp.pm package Temp; printf "Context = %s\n", defined wantarray ? 0+wantarray : 'undef'; # true value, but may cause warning: "nothing";
Result:perl -lib=. -MTemp -we1
Context = 0
But with perl -wc, you do get a warning:
perl -wc Temp.pm
Useless use of a constant in void context at Temp.pm line 3. Temp.pm syntax OK
Replace the string "nothing" with 1, and you're fine:
Temp.pm syntax OK
|
|---|
| Replies are listed 'Best First'. |
|---|