Hi experts,
I have an input file with 2 columns (col_1 and col_2). The information in col_1 can occur more than once throughout the file, whereas the info on column 2 are all unique.
I tried to write a perl program to put all col2 info into one row when the col1 are the same.
...
##I have parsed my file
my $initial=0;
while(my $line=<file>){
if ($col_1 eq $initial ){
push(@table, $col_2);
$initial=$col_1;
} else {
}
}
What should I write in else? so that I can make another row for the $col_2 if the col_1 is different from the previous one?
Regards,
szsy
}
}
I have an input file with 2 columns (col_1 and col_2). The information in col_1 can occur more than once throughout the file, whereas the info on column 2 are all unique.
I tried to write a perl program to put all col2 info into one row when the col1 are the same.
...
##I have parsed my file
my $initial=0;
while(my $line=<file>){
if ($col_1 eq $initial ){
push(@table, $col_2);
$initial=$col_1;
} else {
}
}
What should I write in else? so that I can make another row for the $col_2 if the col_1 is different from the previous one?
Regards,
szsy
}
}