#!/usr/bin/perl ############################################################################### # ajaxWrite: # # Save the content of the form in a file ############################################################################### use CGI "param"; # use CGI param modules @elementNames = param(); # get all FORM element names print "Content-type: text/plain \n"; #text/plain print "\n"; saveData(); # Call saveData to save data ############################################################################### # saveData: Save the form data in the file. ############################################################################### sub saveData { $file = param('_file') || param('_FILE'); # get file name to save data return if (! $file); # exit if no file specified open (OUTPUT , ">> $file") or die("Cannot open output file $file - $!"); foreach $name (@elementNames) { # for each for field if ($name =~ /(_email|_file|_redirect)/i) { # if name is one of these next; # skip it } print OUTPUT "$name=="; # print name of field @values = param($name); # get the values of field foreach $value (@values) { # for each value $value =~ s/\r\n/__/g; # replace newline with __ print OUTPUT "$value##"; # write the field values } print OUTPUT "||"; } print OUTPUT "\n"; close(OUTPUT); print "Saved Successfully"; # send back success } ###############################################################################