in reply to -w in production environment
Eliminating -w is one option that will work and is reasonable if you have completely debugged all the code...If you find a reliable method please tell me how! Another option is to initialise all your values. It depends on how your script is structured as to how you do this. Say you are using CGI.pm, here is what you usually find at the top of my scripts:
#!/usr/bin/perl -wT use strict; use CGI; my $q = new CGI; my $var = $q->param('var') || ''; untaint(\$var); # warning do not do this my @ary = $q->param('options') || (); # this kills the array return of CGI.pm
If you use param queries directly you can do this to define all undefined values:
my @fields = qw(foo bar baz); for (@fields) { $q->param($_,'') unless defined $q->param($_); }
This iterates over the field names an pushes a null string into the value if it is not defined. You can use the same method for a hash:
my @fields = qw (foo bar baz); for (@fields) { $USER{$_} = '' unless defined $USER{$_}; }
Use strict does have an overhead (a very small overhead) - try benchmarking if you are really worried and execution speed is everything. Use mod perl in this case! The reason for leaving use strict and -w active is that your code *will* be modified one day, perhaps by you, perhaps not. If they are active no one has to to remember to reactivate them. If you must kill them comment them out rather than erase them entirely with a note that the should be used for testing modifications to the code.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
---|
Replies are listed 'Best First'. | |
---|---|
(tye)Re: -w in production environment
by tye (Sage) on Jul 06, 2001 at 08:40 UTC | |
by tachyon (Chancellor) on Jul 06, 2001 at 12:35 UTC |