dee00zee has asked for the wisdom of the Perl Monks concerning the following question:
content of file1
a b c d e
content of file2
1 6 11 2 7 12 3 7 13 4 8 14 5 9 23
I want the output to be as follows
1 a 6 11 2 b 7 12 3 c 7 13 4 d 8 14 5 e 9 23
My code didn't return the result I want
#!/bin/perl open(IN,"file1"); open(IN2,"file2"); open (OUT,"> output"); while($str=<IN2>) { @array=split(/\s+/,$str); while($data=<IN>) { @box=split(/\s+/,$data); foreach $item(@array) { splice (@box,2,0,"$array($item)"); print OUT "@box\n"; } } }
20050308 Janitored by Corion: Added code tags.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: read column in perl
by jmcnamara (Monsignor) on Mar 08, 2005 at 09:09 UTC | |
by DentArthurDent (Monk) on Mar 08, 2005 at 12:54 UTC | |
by jmcnamara (Monsignor) on Mar 08, 2005 at 13:29 UTC | |
by wolfger (Deacon) on Mar 08, 2005 at 13:41 UTC | |
|
Re: read column in perl
by ikegami (Patriarch) on Mar 08, 2005 at 07:20 UTC | |
|
Re: read column in perl
by jbrugger (Parson) on Mar 08, 2005 at 07:20 UTC | |
|
Re: read column in perl
by sh1tn (Priest) on Mar 08, 2005 at 08:02 UTC | |
by dragonchild (Archbishop) on Mar 08, 2005 at 13:39 UTC |