Re: How to Disable Perl warnings !!

2012-11-26 Thread Bill Moseley
On Sun, Nov 25, 2012 at 10:09 PM, nitai karmakarnit...@gmail.com wrote:

 Dear all,

 NEED HELP!!!

 I am new to Perl,(only 6 month experience).

 I am working in web based application using CPAN.

 they are using use warnings for enable warnings for in all pm modules.

 There are 3 servers (development, testing and main) respectively where we
 can run the application.

 Now their requirement is, THEY DON'T NEED PERL WARNING FOR
  MAIN SERVER (server 3).


Why?  What the reasoning there?






-- 
Bill Moseley
mose...@hank.org


Re: How to Disable Perl warnings !!

2012-11-25 Thread Jacinta Richardson

On 26/11/12 17:09, nitai wrote:

I am working in web based application using CPAN.

they are using use warnings for enable warnings for in all pm modules.

There are 3 servers (development, testing and main) respectively where we
can run the application.

Now their requirement is, THEY DON'T NEED PERL WARNING FOR
  MAIN SERVER (server 3).
If your code isn't generating any warnings, then leaving it in should 
have no effect in production.  I understand the desire for not keeping 
warnings on just in case they fill up logfiles and stuff, but it is 
worth noting that there is no performance penalty for having use 
warnings turned on if your code isn't generating any warnings.


It should always be safe to leave warnings on in the highly rated 
modules from CPAN.  Obviously this isn't true for all modules on CPAN 
but the well-loved ones shouldn't generate any warnings and as I said 
above having warnings turned on doesn't have any performance penalty.



means, for the firsts 2 server(development and testing)the Perl warning will
display as before but when we run the application in 3rd server the perl
  warning should not display.

IS IT POSSIBLE to write any config file where I can set/change use warnings
  to no warnings depending on the server configuration in run time,
  so any class using  use warnings will replaced by no warnings or
something like that.

HOW TO DO THIS --ANY IDEA..


For your own code, though, if this is essential, I'd suggest having a 
look at the if pragma.


For example:

use if $ENV{USE_WARNINGS}, warnings;

I'm not sure whether the inverse works:

use warnings;
no if $ENV{PRODUCTION}, warnings;

so you'd have to try that.

You can do other things rather than check the environment, but checking 
the environment is an easy example of using the if pragma.


This only works where you can modify the code.  Short of modifying the 
warnings.pm file directly there isn't any way of automatically ceasing 
the use of warnings in all the modules you use without editing those too.


All the best

Jacinta