PERL adding extra Spaceto file or print line

by David Moninger <david(at)IslandTime.com>

 Date:  Fri, 07 Jul 2000 12:30:29 -0400
 To:  hwg-languages(at)hwg.org
  todo: View Thread, Original
Hi folks,

I've written a PERL script to take input from a disk file and display it on 
a web page as data within an embedded form.

The user can then make changes to the data, and when they Submit the form, 
the script rewrites the data file.

Everything is working fine, EXCEPT, each time the file is rewritten, a 
SPACE is being added to the BEGINNING  of each new line??

Below is the salient code for anyone who has time to help me find out how 
to stop this space from being inserted at the beginning of each line.

I read the data from the file with:
	open(BDY, "$filepath") || die "can't open $filepath";
	@body=<BDY>;
	close (BDY);

I write the webpage with
	open(PAGE, "<$filepath") || die "can't open $filepath";

	  while (<PAGE>)
	    {
	    s/%%body%%/@body/g;
	    print $_;
		}
	  close (PAGE);


NOTE   The  s/%%body%%/@body/g;  line above is used to insert the info from 
the datafile into the textarea of the form on the webpage below.

  $filepath points to a file that contains the appropriate HTML that is 
displayed by the above print$_; statement:

	<FORM ACTION="http://www.clientcom/cgi/file_maint.cgi" METHOD="post">
	<BR><BR>
	BODY
	<BR>
	<TEXTAREA COLS=72 ROWS=35 NAME="body" WRAP="soft">%%body%%</TEXTAREA>
	<BR>
		<INPUT TYPE="submit" NAME="SUBMIT" VALUE="SUBMIT_ReWrite">
	</FORM>

Any insights would be appreciated .. this is driving me nuts!

Thanks in advance,

david

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA