Gossamer Forum
Home : General : Perl Programming :

some perl help

Quote Reply
some perl help
Writing this perl script, and now I have this silly I/O problem. I'm writing to a file, and changing 1 line.
So I have to overwrite the whole file with the new line that has been edited, and then add the old one.

But I get spaces between everyline! I am chomping every line, and I add \n to the end of the line that is being written to the file, but I just can't get the lines to "stick together."

Code:
open(WRITEDATA, ">$members2");
flock(WRITEDATA,2);

foreach $entries2 (@indata2){
chomp($entires2);
($number, $name, $email) = split(/\|/, $entries2);

if ($name2 eq $name) {
print WRITEDATA "$number|$newname|$newemail\n";

This is just an example. My code is slightly different.
So each time I do the action this happens:

Quote:
Number|Name|Email

Number|Name|Email

Number|Name|Email

if I do it again this happens:

Quote:
Number|Name|Email


Number|Name|Email


Number|Name|Email


You see?
I had this kind of error in another file, and I didn't check it for a long time, and suddenly I had 5000(!!) lines! And I only had line 10 lines with actual contents. The others were "|||||||" or " ".

Can anyone help?

Thanks.

- kbtune
Subject Author Views Date
Thread some perl help perlman 6238 May 11, 2004, 11:27 AM
Thread Re: [perlman] some perl help
Andy 6109 May 11, 2004, 3:33 PM
Thread Re: [Andy] some perl help
perlman 6111 May 19, 2004, 5:18 AM
Thread Re: [perlman] some perl help
Andy 6098 May 19, 2004, 6:11 AM
Thread Re: [Andy] some perl help
perlman 6099 May 19, 2004, 6:13 AM
Post Re: [perlman] some perl help
Andy 6079 May 19, 2004, 6:17 AM