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?
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)%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
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.
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 statementsif ($webmaster eq "") {
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).### 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 } }
Anyways, I hope you got something from this.
____________________________________________________
** The Third rule of perl club is a statement of fact: pod is sexy.
In reply to Re: Insecurities in my scripting
by PodMaster
in thread Insecurities in my scripting
by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |