in reply to CGI.pm saving state to database
Then when retrieving the value from the database, simply feed it to CGI->new.sub SaveCgi { my( $self, $cgi ) = @_; $cgi = UNIVERSAL::isa($cgi,'CGI') ? $cgi : CGI->new($cgi); my $ret = ""; for my $param ($cgi->param) { my($escaped_param) = $cgi->escape($param); for my $val ($cgi->param($param)) { $ret .= "$escaped_param=".$cgi->escape($val)."&"; } } chop $ret; # simples way to remove last & return $ret; }
You may also wanna investiage CGI::Session as well as CGIS.
update: I adopted SaveCgi a long time ago from CGI.pm's save
#### Method: save # Write values out to a filehandle in such a way that they can # be reinitialized by the filehandle form of the new() method #### 'save' => <<'END_OF_FUNC', sub save { my($self,$filehandle) = self_or_default(@_); $filehandle = to_filehandle($filehandle); my($param); local($,) = ''; # set print field separator back to a sane value local($\) = ''; # set output line separator to a sane value foreach $param ($self->param) { my($escaped_param) = escape($param); my($value); foreach $value ($self->param($param)) { print $filehandle "$escaped_param=",escape("$value"),"\n"; } } foreach (keys %{$self->{'.fieldnames'}}) { print $filehandle ".cgifields=",escape("$_"),"\n"; } print $filehandle "=\n"; # end of record } END_OF_FUNC
|
MJD says you can't just make shit up and expect the computer to know what you mean, retardo! I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests. ** The Third rule of perl club is a statement of fact: pod is sexy. |
|
|---|