pimperator has asked for the wisdom of the Perl Monks concerning the following question:
This is my tab delimited input file
Name \t Street \t AddressThis is how I want my output file to look like
Street \t Address \t Address(yes duplicate the next two columns) My output file looks like this instead
Street \t Address \n \t Address
What is going on with perl? This is my code.
open (IN, $ARGV[0]); open (OUT, ">output.txt"); while ($line = <IN>){ chomp $line; @line=split/\t/,$line; $line[2]=~s/\n//g; print OUT $line[1]."\t".$line[2]."\t".$line[2]."\n"; } close( OUT);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Incorrectly adding a newline character
by McA (Priest) on Oct 08, 2013 at 05:00 UTC | |
|
Re: Incorrectly adding a newline character
by vinoth.ree (Monsignor) on Oct 08, 2013 at 04:38 UTC | |
|
Re: Incorrectly adding a newline character
by Genis200 (Initiate) on Oct 08, 2013 at 04:34 UTC | |
|
Re: Incorrectly adding a newline character
by Laurent_R (Canon) on Oct 08, 2013 at 06:02 UTC | |
|
Re: Incorrectly adding a newline character
by Lennotoecom (Pilgrim) on Oct 08, 2013 at 07:58 UTC |