I’m working on a Perl CGI script about 4000 lines big. Our coding style includes use strict and use warnings usually, but in this particular (quite old) file, “use warnings” is commented out, with the comment stating that enabling warnings would flood the Apache log.
Now I plan to separate some code into a new subroutine. I want to use warnings at least there. How can I safely limit the effect of use warnings to one subroutine? Will just placing the use clause inside the subroutine do the job?
Yes, the use of
use warningwill be in the scope in which you have written it.Writing
use warninginside a sub will only affect the giving routine (or block).example snippet
output
Note that no warning is thrown about the use of
print my $c.What does the documentation say?