From: Dana Smith To: pm-help@listserv.oit.unc.edu Subject: perl -w & strict? Date: Fri, 7 May 1999 12:04:32 -0400 So I'm trying to use "perl -w" and "use strict" along with Getopt::Std. Is it true I have to call "$opt_F" by its full name "$main::opt_F" under "use strict"? I have several command line flags that are only checked on one line in the script. "perl -w" seems annoyed by this: Name "main::opt_F" used only once: possible typo at rf_queue line 570. Anyway to shut this up besides turning off -w? Thanks in advance for any info. > Dana L. Smith > SouthPeak Interactive > (919) 677-4499 x4116 > Dana.Smith@southpeak.com > > To: dasmit@southpeak.com cc: pm-help@listserv.oit.unc.edu Subject: Re: perl -w & strict? Date: Fri, 07 May 1999 12:26:13 -0400 From: "John M. Klassa" >>>>> On Fri, 7 May 1999, "Dana" == Dana Smith wrote: Dana> So I'm trying to use "perl -w" and "use strict" along with Dana> Getopt::Std. Is it true I have to call "$opt_F" by its full Dana> name "$main::opt_F" under "use strict"? I'm not sure about this one, but it sounds reasonable. $opt_F comes into existence "automatically", via the Getopt module, right? That is, its existence is what alerts you to the -F flag having been passed, rather than some specific value in $opt_F (in which case you could "my $opt_F" first). Dana> I have several command line flags that are only checked on one Dana> line in the script. "perl -w" seems annoyed by this: Name Dana> "main::opt_F" used only once: possible typo at rf_queue line Dana> 570. Anyway to shut this up besides turning off -w? Use it again, in some trivial way... Something like: if ($opt_F) { whatever } $opt_F = $opt_F; This is a kludge, but it'll work... It's as bad as having to do stupid things like this, in Emacs, to get the font-lock stuff to lock on again: if (/"/) # extra " for Emacs { # whatever } You can also turn warnings (and strict) off on a block by block basis, so that parts of your code can be without it. For example, to get rid of the warning, you may try something like: #!/usr/bin/perl -w use strict; { $^W = 0; # turn warnings off no strict; if ($opt_F) { # whatever } } HTH, John -- John Klassa / Alcatel USA / Raleigh, NC, USA I'm not a muffin. -- Hannah, age 2 Date: Fri, 07 May 1999 12:52:19 -0400 From: Doug Seay To: dasmit@southpeak.com CC: pm-help@listserv.oit.unc.edu Subject: Re: perl -w & strict? Dana Smith wrote: > > Anyway to shut this up besides turning off -w? I haven't used this magic in years, but I handled it by pre-initalizing the variable $opt_F = 0; This way it is there at least twice. - doug