Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This is only happening when I delete the contents of the file on the server. If I do it by clearing the contents of the textarea through a brower and pass them to the script, there is always 1 blank character.
I am still new to all of this, but am reading a book right now and trying things like chop, chomp, truncate.. ?
Am I close? Or have I gone completely mad?!
Here is the code that writes what was in the textarea to file:
#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use strict; use CGI ':standard'; my $list; my @changes = param('tellmessage'); open(FILE, ">eetnlinks.txt") || die "Can't open file!"; flock(FILE, 2) || die "Can't lock file!"; #truncate(FILE,0); foreach $list (@changes) { chomp ($list); print FILE "$list\n"; } close(FILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Always leaving one space in file
by zby (Vicar) on Apr 23, 2003 at 15:07 UTC | |
by Anonymous Monk on Apr 23, 2003 at 15:23 UTC | |
by vek (Prior) on Apr 23, 2003 at 15:31 UTC | |
by zby (Vicar) on Apr 23, 2003 at 15:32 UTC | |
by Anonymous Monk on Apr 23, 2003 at 15:42 UTC | |
by zby (Vicar) on Apr 23, 2003 at 17:41 UTC | |
by Anonymous Monk on Apr 23, 2003 at 15:32 UTC |