• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Need a little CGI help...

JL™

New Member
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.

#!/usr/bin/perl
use CGI qw:)cgi);

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.
 
Back
Top