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



SirAnvil
Deleted

Feb 23, 2001, 2:00 PM


Views: 484
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
food=pizza
toy=buzz lightyear
music=huh?

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?

SirAnvil
www.christiangamers.org


japhy
Enthusiast

Feb 24, 2001, 6:01 AM


Views: 478
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.


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

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


SirAnvil
Deleted

Feb 24, 2001, 7:18 AM


Views: 476
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?

name=value

$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>

SirAnvil
www.christiangamers.org