I have recently been installing lots of perl cgi scripts onto an old
netscape fasttrack 2.? server running under solaris. Perl is version
5.004. My scripts which run fine on other servers are producing lots
of warning messages under fasttrack.
It looks as though the "-w" command line switch has been globally
turned on for all CGI scripts. How has this been done, how do I stop
it?
PS. I do NOT have a -w flag on the first line of my script!
--
Fergus McMenemie Email:fer...@twig.demon.co.uk.
Technical Basis Phone:(UK) 07721 376021
Unix/Mac/Intranets Analyst Programmer
fer...@twig.demon.co.uk (Fergus McMenemie) writes:
> I have recently been installing lots of perl cgi scripts onto an old
> netscape fasttrack 2.? server running under solaris. Perl is version
> 5.004. My scripts which run fine on other servers are producing lots
> of warning messages under fasttrack.
>
> It looks as though the "-w" command line switch has been globally
> turned on for all CGI scripts. How has this been done, how do I stop
> it?
a) perl 5.004 is pretty out of date.
b) Globally enabling warnings (in the server) seems kind of silly.
c) Perhaps you should fix the scripts to not produce warnings.
d) In modern versions of perl you can turn off warnings lexically.
See the perllexwarn manpage.
e) See the perlvar manpage, the $^W entry, if you really, really don't
want to fix your code.
Jon
--
Two are better than one, because they have a good return for their
work: If one falls down, his friend can help him up... Though one
may be overpowered, two can defend themselves. A cord of three
strands is not quickly broken. -- Ecclesiastes 4:9,12 (NIV)
> [I'm ignoring your Followup-To: netspace.general.]
>
> fer...@twig.demon.co.uk (Fergus McMenemie) writes:
>
> > I have recently been installing lots of perl cgi scripts onto an old
> > netscape fasttrack 2.? server running under solaris. Perl is version
> > 5.004. My scripts which run fine on other servers are producing lots
> > of warning messages under fasttrack.
> >
> > It looks as though the "-w" command line switch has been globally
> > turned on for all CGI scripts. How has this been done, how do I stop
> > it?
>
> a) perl 5.004 is pretty out of date.
Yes, but its what the customers 'ISP' is using! (this is on a gov
intranet)
> b) Globally enabling warnings (in the server) seems kind of silly.
Yep, I havent seen it before, and it is silly.
> c) Perhaps you should fix the scripts to not produce warnings.
Yep, fixing 90% of the errors might take a few days. The other 10%
might take weeks. Besides most the scripts are years old and work
fine. I have started fixing a few scripts and everything so far is
trivial.
> d) In modern versions of perl you can turn off warnings lexically.
> See the perllexwarn manpage.
>
> e) See the perlvar manpage, the $^W entry, if you really, really don't
> want to fix your code.
Thanks!
> Jon
> a) perl 5.004 is pretty out of date.
Indeed
> b) Globally enabling warnings (in the server) seems kind of silly.
Silly? Maybe it's a policy decision by the administrator. Maybe
there's a general CGI policy on that server, that all scripts are to
run clean under this discipline. I could think of _much_ sillier
things to do! (Like running an out of date version of Perl, for one).
cheers
Its tough but a vendor supplies and manages the intranet. They charge an
utter fortune to upgrade anything. However.....
I am unfimiliar with perl internals, and was wondering which file,
within the perl distribution, I would fiddle if I was to set $^W
globally. Just supposing I wanted to do such a silly thing!
> On Mar 14, Jon Ericson inscribed on the eternal scroll:
>
>> b) Globally enabling warnings (in the server) seems kind of silly.
>
> Silly? Maybe it's a policy decision by the administrator. Maybe
> there's a general CGI policy on that server, that all scripts are to
> run clean under this discipline.
I guess I assumed that it *was* an administrator or site policy, and I
*still* think it's silly. In general, warnings should always be
enabled, but there are legitimate reasons to have warnable code. The
OP suggested one--legacy code. Or, perhaps you know what you're doing
and the warning should be ignored. The 'Deep recursion' warning comes
to mind. Occasionally, a module will have code that sets off a
warning. It is for reasons like this that we have lexical warnings.
The best reason I can think of for globally enabling warnings is to
encourage people to write better code. But people will take the path
of least resistance and disable warnings in their scripts, rather than
fix the problems. $^W isn't exactly a secret. Even warnings clean
code can be buggy. (Trust me, I know. :)
I suppose I haven't thought of the non-silly reasons to do this
because I don't administer a CGI server.
Hey, spooky stuff, I just read that and decided to experiment:
#!perl -w
use strict;
sub recur {
my $n = 1 + shift;
print "$n,";
recur($n) if $n < 100; # At 99 there is no warning
} # but at 100 there is
recur(0);
The strange thing is that Perl prints the "Deep recursion"
warning *before* it runs the code! How can it tell how
deep the recursion is going to be without running it?
I can even change that 100 into a function call of seemingly
arbitrary complexity and it *still* knows! Oooh, there be
sinister black magic at work here...
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
> #!perl -w
>
> use strict;
>
> sub recur {
> my $n = 1 + shift;
> print "$n,";
> recur($n) if $n < 100; # At 99 there is no warning
> } # but at 100 there is
>
> recur(0);
>
> The strange thing is that Perl prints the "Deep recursion"
> warning *before* it runs the code! How can it tell how
> deep the recursion is going to be without running it?
>
> I can even change that 100 into a function call of seemingly
> arbitrary complexity and it *still* knows! Oooh, there be
> sinister black magic at work here...
stderr is not buffered and stdout is. If you add $|=1 or use print
"$n\n"; you will see the warning in the expected location.
You're starting to count from 0, not 1. Were you surprised by number
of calls required to set off the warning or just the location of the
warning message?
Oh I see! Mystery solved, thanks. :-)
> Were you surprised by number of calls required to set off the
> warning or just the location of the warning message?
The latter. Now I understand, thanks.
--
James Taylor <james (at) oakseed demon co uk>
Based in Southam, Cheltenham, UK.
Fingerprint: F19D803624ED6FE8 370045159F66FD02