You can use CGI to get and set the parameters passed to your script in the URL string:
your_script?foo=bar&baz=buzz&baz=bizz
or POSTed in fill-out forms.
$bar = param('foo'); # scalar
$baz = param('baz'); # scalar
@baz = param('baz'); # list
param('foo' => 'BIG BAR'); # set foo to scalar
param('foo' => ['VERY','BIG','BAR']); # set foo to list
$q = new CGI;
$bar = $q->param('foo');
You can create multiple independent CGI objects and save and restore their state:
$q = new CGI;
$r = new CGI; # starts out being the same as $q
$r->param('foo' => ['VERY','BIG','BAR']); # now $r is different
# save state to filehandle
open (FILE,">/tmp/cgi.txt");
$r->save(\*FILE);
# restore state from filehandle
open (F,"/tmp/cgi.txt");
$i = new CGI(\*F);
# save state to URL
$query = $q->query_string();
# restore from URL
$j = new CGI($query);
Vars() gives you a nice tied interface to parameters:
$q = new CGI;
$v = $q->Vars;
print $v->{'foo'};
print $v->{'bar'};
@baz = split "\0",$v{'baz'};
|
| Contents | Next |