#!/usr/local/bin/perl $freelinks = '/system/path/to/freelinks.html'; $freelinksurl = 'http://www.yourdomainname.com/freelinks.html'; # Get the form variables if ($ENV{'REQUEST_METHOD'} eq 'GET') { $querystring = $ENV{'QUERY_STRING'}; } else { read(STDIN, $querystring, $ENV{'CONTENT_LENGTH'}); } @arrnameval = split(/&/, $querystring); foreach $namval (@arrnameval) { ($nam, $val) = split(/=/, $namval); # replace + with space $val =~ tr/+/ /; # translate hex values $val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORMDATA{$nam} = $val; } $title = $FORMDATA{'yourtitle'}; $title =~ s/<[^>]*>//g; $url = $FORMDATA{'yoururl'}; $url =~ s/<[^>]*>//g; $category = $FORMDATA{'category'}; $category =~ s/<[^>]*>//g; # Read content open(FREELINKS,"$freelinks"); @arrfreelinks = ; close(FREELINKS); #Save back new content open(FREELINKS,">$freelinks"); foreach $line (@arrfreelinks) { print FREELINKS "$line"; if ($line =~ "--newentries$category--") { print FREELINKS "\n   - $title
\n"; } } close(FREELINKS); print "Content-type: text/html\n"; $flinks = "$freelinksurl\n\n"; print qq(Location: $flinks); return;