PerlMonks: Thanks for all the help.
I have another question. I am trying to merge a given column from individual lfiles to a single text file. This is how the files look like:
input1
freq data1
1 2
2 5
3 10
input2
freq data2
1 12
2 50
3 10
input3
freq data3
1 10
2 25
3 11
Combined output
freq data1 data2 data3
1 2 12 10
2 5 50 25
3 10 10 11
I have difficulty writing to a certain column in output
following code attempts to take second column from input file and writes to second column in output file, but not successful.
use strict; use warnings; open(my $file2, '<', "data1.txt") or die "failed to open 'output_1.txt + $!"; open(my $file3, '>>', "combined.txt") or die "failed to open 'combined +.txt $!"; while (<$file2>) { chomp; # delete new line character my @combined_data = $file3; my @list_file = split; print "$combined_data[1]" "$list_file[1]\n"; } close $file2; close $file3;
In reply to Merging Columns from multiple files into a single file by ikhan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |