##
#!/usr/bin/perl -w
use strict;
use CGI;
my $query = new CGI;
# get all the name/value pairs in a hash
my %details = $query->Vars;
my $entry = join "#", values %details;
open (GBOOK, ">> guestbook.txt") or die "Oops, Perl says $!\n";
print GBOOK "$entry\n";
close GBOOK;
# now print some HTML out using a herepage
my $html_entry = join "
\n", values %details
print << HTML;
Content-type: text/html
Thanks!
Thanks!
Here is the data stored.
$html_entry
Click here to view your post
HTML
__END__
##
##
# encode all the '#' chars before we join
s/#/%35/g for values % details;
# now the only '#' chars represent our delimiter
my $entry = join "#", values %details;
# getting the data from the file we reverse the process
# first split on the '#' char to get our values
my @values = split "#", ;
# now unencode any encoded '#' chars in @values
s/%35/#/g for @values;