lijewski@theory.tn.cornell.edu (Mike Lijewski) (05/11/91)
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. -- Mike Lijewski (H)607/272-0238 (W)607/254-8686 Cornell National Supercomputer Facility ARPA: mjlx@eagle.cnsf.cornell.edu BITNET: mjlx@cornellf.bitnet SMAIL: 25 Renwick Heights Road, Ithaca, NY 14850
tchrist@convex.COM (Tom Christiansen) (05/12/91)
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."
rbj@uunet.uu.net (Root Boy Jim) (05/16/91)
tchrist@convex.COM (Tom Christiansen) writes:
?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
You didn't go and put real control Ws
into your script now did you?
For shame, for shame!
--
[rbj@uunet 1] stty sane
unknown mode: sane
raymond@math.berkeley.edu (Raymond Chen) (05/16/91)
In article <1991May16.002134.11005@uunet.uu.net>, rbj@uunet (Root Boy Jim) writes: >You didn't go and put real control Ws into your script now did you? I can see it now... invisible control-W | v $ perl -we '$=1;' Control character in script may cause problems at /tmp/perl-ea03984 line 1. perl -e 'print"Just another ",$0=~/(\w+)-/," hacker,"'