in reply to Insecurities in my scripting

... rude ... though I'm new ...

I gotta say the easiest way to get good advice is to swallow your pride. What's a little abuse in exchange for great tips? Nevermind

Why did you include %{} around your call to vars?

%form = %{$query->Vars}; # perl -MCGI=Vars -e" %a=Vars();print for keys %a " a=b c=d # perl -MCGI=Vars -e' %a=Vars();print for keys %a ' a=b c=d
I'd assume because you didn't know what the documentation clearly states (i know there is a ton of it, but we're only interested in the functions we use)
Many people want to fetch the entire parameter list as a hash in which the keys are the names of the CGI parameters, and the values are the parameters' values. The Vars() method does this. Called in a scalar context, it returns the parameter list as a tied hash reference. Changing a key changes the value of the parameter in the underlying CGI parameter list. Called in a list context, it returns the parameter list as an ordinary hash. This allows you to read the contents of the parameter list, but not to change it.
if ($webmaster eq "") {
I see a lot of people coming from javascript doing this type of stuff, but it's utterly unneccessary. if($webmaster) would suffice, if all you required is a true value. Consider this example instead of that chain of if/else statements
### Make sure things are being completed, die slackers! my %youMustProvide = ( message => "Only a severe slacker would try to submit a form without l +eaving a message!\n", usermail => "Ok, buddy, how do you expect me to email you back if you +FORGET to leave yoru email address?!?\n", username => "Please click back and type in your name so I can spy on y +ou!\n", ); for my $key(keys %youMustProvide ) { # unless the parameter is present, and has a true value unless(exists $form{$key} and $form{$key} ) { # notify the user of his *forgetfulness* print $youMustProvide{$key}; # and do whatever else you need to in such an instance } }
Some folks call it a "dispatch" table, and use it do do more than merely printing an error message, like providing regex patterns or callbacks for argument validation. There's probably even a module to do something like this (i know there is, but the name escapes me at the moment).

Anyways, I hope you got something from this.

____________________________________________________
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Insecurities in my scripting
by sulfericacid (Deacon) on Nov 21, 2002 at 08:12 UTC
    Thanks so much for your help! I will reread that like a million times til i figure it out, I think I might try your dispatch table, that seems a lot neater than what I typically do.

    Thanks again!!

    sulfericacid