cdguitar01 has asked for the wisdom of the Perl Monks concerning the following question:
| starts | becomes | becomes |
|---|---|---|
| 1 2 3 |
1 2 3 |
1 2 3 |
I'm assuming this is caused by the \n characters being added on to each line of the STDIN, but I don't think chomp works in this case, at least I haven't been able to make it work.
This is the perl script which updates the file by recieving two form parameters; a file name, and the actual text that was in the text area.
How does one perform a chomp on each line of text as it comes in, is that even possible, or am I just thinking about this the completely wrong way and if so, how should I be going about this process.#! c:\perl\bin\perl.exe -w use strict; use CGI; my $query = CGI->new(); my @names = $query->param; my $file_name = $query->param( $names[0] ); my $file_path = '../htdocs/safe/internship/u_texas.txt'; my $new_text = $query->param( $names[1]); chomp(my $success = open OUT, ">$file_path"); # test for open omitted for space concerns print OUT $new_text; close OUT;
Thanks,
Chris (Boston,USA)
Edit by dws to add <code> tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extra (\n)'s in the file I'm updating?
by valdez (Monsignor) on Jan 11, 2003 at 11:08 UTC | |
by cdguitar01 (Monk) on Jan 11, 2003 at 18:56 UTC | |
|
Re: Extra (\n)'s in the file I'm updating?
by vek (Prior) on Jan 11, 2003 at 15:10 UTC | |
by cdguitar01 (Monk) on Jan 11, 2003 at 19:08 UTC | |
|
Re: Extra (\n)'s in the file I'm updating?
by poj (Abbot) on Jan 11, 2003 at 13:24 UTC | |
by cdguitar01 (Monk) on Jan 11, 2003 at 19:01 UTC | |
|
Re: Extra (\n)'s in the file I'm updating?
by Chady (Priest) on Jan 11, 2003 at 10:50 UTC | |
by cdguitar01 (Monk) on Jan 11, 2003 at 18:53 UTC |