"Amit Saxena" schreef:

> What's the difference between "perl -w" and "use warnings" in perl ?

The -w is the old fashioned way, but still fine for one liners.

> If there is no difference,

There is an important difference, see warnings and perllexwarn.


> then the "use warnings" can be removed from the perl programs
> and replace them with "perl -w".of removing "use warnings".

It's exactly the other way around: stop using -w, and have warnings
active in every scope feasible.



Some people put a C<no warnings 'syntax';> right after the C<use
warnings;>
http://www.google.co.uk/search?q=no.warnings.syntax
for good reasons, and with a modern Perl that is quite safe:


$ perl -Mwarnings -le'
    ($x, $y, $z) = (3, 4, 2);
    print ($x + $y) * $z;
'
print (...) interpreted as function at -e line 3.
Useless use of multiplication (*) in void context at -e line 3.
7


$ perl -Mwarnings -le'
    no warnings "syntax";
    ($x, $y, $z) = (3, 4, 2);
    print ($x + $y) * $z;
'
Useless use of multiplication (*) in void context at -e line 4.
7


-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to