Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!convex!usenet From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: turning on warnings from within a script Message-ID: <1991May11.183203.5273@convex.com> Date: 11 May 91 18:32:03 GMT References: <1991May11.154445.655@batcomputer.tn.cornell.edu> Sender: usenet@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 27 Nntp-Posting-Host: pixel.convex.com From the keyboard of lijewski@theory.tn.cornell.edu (Mike Lijewski): :Is there any way to turn on the "-w" switch from within Perl? What I :would like to be able to do is turn on the "-w" switch from inside of :a Perl script, depending on the options I pass to the script. :Specifically, if I put some debugging code in my script, which I :toggle with a "-d" switch, I would like to enable Perl's warning :messages as well. I don't like running with "-w" enabled since Perl :warns about some things which are perfectly legal. The writeable $^W variable contains the value of the -w switch in 4.0 version of perl. For example, the first assignment here gives a warning, but the second one doesn't. $ = 1; # enable -w $a = $b[$i]; # generate warning $ = 0; # disable -w $c = $d[$i]; # remain silent Note that this only applies the run-time warnings, not compile-time ones (unless you're in an eval and thus compiling). This means that you won't get "Possible typo" messages, but you will get "uninitialized variable" messages. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "So much mail, so little time."