darkreign has asked for the wisdom of the Perl Monks concerning the following question:
now its error exists under the subroutine read_fields. foreach $f ($req->param) returns that param is undefined. but if you look its defining value comes from the submitted form, so it will be undefined til a form is submitted ... why is it reading into the subroutine in that fashion when it has the data to define that section. As for CGI:Carp qw/fatalsToBrowser/; i used it to see what it would do but ... i dont want to use something of that nature, im wanting the script to return its own error warnings. at present it is simplistic, but wanting to develop it further. I will however keep that in mind when testing CGI scripts, because it does report some nice things. On my script it reported only things that were predeclared and not set anywhere,not anything serious. So thanks to suggesting it. strict and warnings On my script it reported only things that were predeclared and not set anywhere. But did return that param was undefined so on final take from those 3 : predeclaration on variables later defined in the script is ok this even being a direct declaration to reading the submitted form to defining param, its returning undefined in sub return_fields. well like i said if the form is submitted it has the defined values so why is it reading into the sub and undefining it, when it has the data to define it being sent. same error only that one remains. im stumped why the data to be defined is getting undefined, or is it that its reading the sub and finding its undefined and not even bothering with the submitted data that will define it. will look into it more over the week and try some things ... if not ill revert back to my own cgi processing subs that worked before.if ($USE_CGI_MODULE == 1) { use CGI; $\ = "\n"; $req = new CGI; print $req->header; &read_fields; } else { # cgi process variables here if CGI.PM is not available } sub read_fields { my(%fields); foreach $f ($req->param) { $name = &clean_name($f); $fields{$f}{name} = $name; $value = &clean_value($f); $fields{$f}{value} = $value; } return(%fields); } sub clean_name { local($f) = shift; $f =~ s/^F\d+_//; $f =~ s/_/ /g; return($f); } sub clean_value { local($f) = shift; local(@val, $val); @val = $req->param($f); $#val-- unless $val[-1] =~/\S/; $val = join(" - ", @val); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: needing help with a cgi form processor
by rhesa (Vicar) on Feb 27, 2006 at 02:07 UTC | |
|
Re: needing help with a cgi form processor
by McDarren (Abbot) on Feb 27, 2006 at 02:10 UTC |