RE: Re: script adding spaces into a file for no reason...
by JoeG (Initiate) on May 20, 2000 at 00:44 UTC
|
| [reply] |
RE: Re: script adding spaces into a file for no reason...
by JoeG (Initiate) on May 20, 2000 at 00:52 UTC
|
oh.. wait.. ;-)
Now its inserting like 3 ADDITIONAL paragraph marks (or hard returns) -- whatever you want to call them.. The only way I could tell was by pasting the code into MS Word and seeing them when I enabled "show P marks".....
any ideas for this problem?
Joe | [reply] |
|
I don't see any extra newlines... Where are they appearing?
| [reply] |
|
They're hidden ... MS Word sees them when i paste, and apparantly my news app sees them.. because it's really messing up the output.. ;-(
| [reply] |
RE: Re: script adding spaces into a file for no reason...
by Anonymous Monk on May 20, 2000 at 00:59 UTC
|
<textarea>@{join("",@text)}</textarea>
the proposed solution still returns an array; It needs to be taken out of array context.
Instead of print <<END ,
try:
print "<textarea>" . join ( "", @text ) ."</textarea>\n" ;
This is presuming, of course, that the "\n" is already on the end of each element of @text. if not, you might want to join them with "\n".
Also, be aware that some browsers may take it upon themselves to make each line ending a "\n\r" - especially if you cut and paste into the textarea. I make it a habit to:
$input =~ s/\r//g ;
On all submitted form values to clean it up.
| [reply] |
|
| [reply] [d/l] |
|
Thanks to everyone for their help. It's working now. Here's the core file saving code for your reference. It removes unncessary line returns, etc.
if (defined $query->param('Submit')) {
open NEWNEWS, "> cgi/news.txt" || die "Cannot open file: $!";
$result = $query->param('content');
$result =~ s/\r//g;
print NEWNEWS $result;
close(NEWNEWS);
print '<p>Saved your changes.</p>';
$query->delete('Submit');
}
JoeG | [reply] [d/l] |
|
ack! (look at the html source to decipher previous reply)
| [reply] |
|
I tried reading the source .. and used that code-- it runs w/o errors, but unfortunately didn't fix..
I used: print "<textarea>" . join ( "", @text ) ."</textarea>\n" ;
hmm.. this is really strange. any other ideas?>
Joe
| [reply] [d/l] |
|
I'm not sure what the problem is, but I'll add a couple of
ways to interpolate an array without spaces...
print "<textarea>", @text, "</textarea>\n";
# (unless you've redefined $,)
...or...
{
local $";
print "<textarea>@text</textarea>\n";
}
| [reply] [d/l] [select] |