sub encode { my $encode = shift; $encode =~ s/([^\w\s.!~*()'-=&])/sprintf "%%%02X", ord($1)/eg; $encode =~ tr/ /+/; return $encode; } sub decode { my $decode = shift; $decode =~ tr/+/ /; $decode =~ s/%([a-f\d][a-f\d])/pack("c",hex($1))/ige; return $decode; } $str = qq/Arnie said, "I'll be back!"/; $enc = encode ($str); $dec = decode ($enc); print "$enc\n$dec"; #### #!/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;