Home: Perl Programming Help: Beginner:
The State of a form


Feb 23, 2001, 2:00 PM

Views: 503
The State of a form

I was playing w/ CGI.pm and using it's feature to save the state of a form to a file. I loose info somewhere and could not figure out where so I got the bright Idea of doing basically what the CGI.pm was already doing to see if I can prevent that leak.

I save a list of all my name/value pairs to a file much like this
toy=buzz lightyear

Okay so now that it's sitting pretty in a nice file, I want to call that file and place each name/value pair in variables. Each variable being identical to the name and it's contenst being the value.

Does anyone have a slick code piece to perform this seemingly simple task? If so, could I possably get an explenation of the said code snip?



Feb 24, 2001, 6:01 AM

Views: 497
Re: The State of a form

Don't do that. Don't make individual variables for each one. Use a the CGI object. Your method will break with checkboxes, multiple-select, or any other field that is duplicated.

use CGI; 
open INPUT, "query-file";
my $quer = CGI->new(\*INPUT);
close INPUT;

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author


Feb 24, 2001, 7:18 AM

Views: 495
Re: The State of a form

so doing it this way would allow me to refer to the object any time I need it right?


$something = $query->param('name');
do something with $something

Is that what your saying? So if that's right then I can pull the info as I need it and not all at one time right? Or am I missing the point all together?

as for my original problem I figured out what it was. I knew the leak was not the CGI.pm and somewhere in my code and it was. <g>