in reply to Re^2: warnings pragma anomaly
in thread warnings pragma anomaly
As the return value of this expression is returned and checked for truthness, it's not used in a void context.
Are you sure about that? If you end a package with just: 1; no warning is produced; but if you end it with just: 42;:
C:\test>perl -Mstrict -w package x; sub f{ 1 } 42; ^Z Useless use of a constant in void context at - line 5.
Although it is returned and checked at runtime; at the point of parsing it is in a void context.
And you can't avoid that by prefixing a return statement either:
C:\test>perl -Mstrict -w package x; sub f{ 1 } return 42; ^Z Can't return outside a subroutine at - line 3.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: warnings pragma anomaly
by choroba (Cardinal) on Oct 19, 2015 at 22:25 UTC | |
by muba (Priest) on Oct 19, 2015 at 23:22 UTC | |
by choroba (Cardinal) on Oct 20, 2015 at 07:45 UTC | |
by BrowserUk (Patriarch) on Oct 19, 2015 at 22:40 UTC |