I'm writing a CGI perl script that will open a file on my server, view the contents of it, and, if I choose, add information to the file. The problem is that I need the script to format the text I put in the box EXACTLY the way I wrote it. The way it is now, it writes everything on one line. Can anyone help me. Here is a copy of the code.
Any idea on how I can get the script to format the text exactly how I write it and not all on one line? Thanks in advanced.
#!/usr/bin/perl
use CGI qwcgi);
my ($in) = new CGI;
$data = $in->param('data');
$fullfile = '/path/to/file.txt';
$action = '/test/perlscript.cgi';
print "Content-type: text/html\n\n";
if ($ENV{'QUERY_STRING'} eq "edit") {&edit}
&main;
exit;
sub main {
open (DATA, "$fullfile");
$lines = join ("", <DATA>);
close DATA;
print<<"ShowHTML";
<html><title>Edit</title><body>
<FORM METHOD=POST ACTION="$action?edit">
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>
<tr>
<TD VALIGN=MIDDLE>
ShowHTML
$lines =~ s/<\/TEXTAREA/<\/TEXT-AREA/ig;
print<<"ShowHTML";
</td><TD ALIGN=LEFT VALIGN=TOP>
<TEXTAREA NAME="data" ROWS=20 COLS=60 wrap=true>$lines</TEXTAREA></td></tr></TABLE>
<input type="submit" value="Update"></body></html>
ShowHTML
}
sub edit{
open(DATA,">$fullfile");
print DATA $data;
close(DATA);
print "<html><head><title>Success</title><META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=$action\"></head><body>Your Information has been updated!</body></html>\n";
exit;
}
Any idea on how I can get the script to format the text exactly how I write it and not all on one line? Thanks in advanced.