I hate having to send the same parameters to a script but there are times when you need to vary from your defaults. I came up with this code (using CGI to handle parameter parsing) with the help of a www.perlguru.com user: mhx. You can define a default for your parameters and if the user supplies a value under the same argument name, the users value is used; otherwise your default is used. Insert into your own code if you need this sort of capability. P.S I could only get 'join "&" => @ARGV' to work this way for @ARGV handling even though CGI shuold deal with it directly. Enjoy!
#!/usr/bin/perl
# define script defaults (change these to suit your needs or supply th
+em in your script calls)
my %defaults = ( foo => "bar",
bar => "foo",
... => ...,
);
# to handle parameter passing
use CGI;
# get the script parameters; 1st from the ARGV array (in the case of S
+SI calls) then the QUERY_STRING
if (@ARGV) { $input = new CGI ( join "&" => @ARGV ); } else { $input =
+ new CGI; }
# set the values for parameters omitted by user to the %defaults value
+s
for ( keys %defaults ) { $input->param(-name=>$_,-value=>$defaults{$_}
+) unless $input->param($_); }
#########
# the rest of your program here
#########