I can't type much, but here is save from CGI.pm. As you can see, its fairly easy to adopt this to your needs very quickly (me type left hamd only)
#### 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
you can also look into perltie and tutorials to tie a filehandle to a scalar, but I think it'd be easier to adopt the above code.
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;" |