Hello,

I have the following code, but it seems that the first array can't be used in the second while loop for comparison. Can someone tell me how this array can be used in the second while loop?

# !/usr/bin/perl

#use strict;
use warnings;

###############################
######### FUNCTIONS ###########
###############################

#Input: Inserted tab delimited text files.
#Output: Corrected file.
#Function: Reads the inserted files and corrects the descriptions.

sub file_handling{

my $column;
my $general;
my @results;
my @results1;
my @results2;

#Opening the files.
my $filename1 = "LlactisKF147_annotation.csv";
open(FILE1, '<', $filename1) or die "Can't open file: $filename1";

my $filename2 = "LlactisKF147_annotation+IGS_versie2.csv";
open(FILE2, '<', $filename2) or die "Can't open file: $filename2";

my $filename3 = "Translated_file.csv";
open(FILE3, '>', $filename3) or die "Can't open file: $filename3";

my $filename4 = "Not_in_translationlist.csv";
open(FILE4, '>', $filename4) or die "Can't open file: $filename4";

#Reads file number 2 and skipping the first line.
my $first_line2 = <FILE2>;

while(my $line = <FILE2>) {
my $line2 .= $line;

#Check if column is defined.
if (! defined $column) {
$column = $line2;


}else {
#Split the lines to form arrays.
@results = split("\t", $line);

if ($results[1] =~ m/Original/ && $line2 !~ /^\s*$/ ){
$general = $results[10];
}elsif ($results[9] =~ m/\*/ || $results[9] =~ m/\@/ || $results[9] =~ m/ts/ || $results[9] =~ m/ns/ ){
if ($results[6] eq ''){
$results[10] = "Hypothetical protein"
}else{
$results[10] = $general;
}
}

}


#Reads file number 1 and skipping the first line.
my $first_line1 = <FILE1>;

while(my $line = <FILE1>){

my $line1 .= $line;

#Split the lines to form an array.
@results1 = split ("\t", $line1);

#Check if description of file 1 is in file 2.
# Is this true then change the discription to the description in file 2.
if ($results1[6] eq $results[6]){
$results1[6] = $results[10];
print FILE3 Dumper (\@results1);
}else{
print FILE4 "hoi";
}



}

}

close(FILE1);
close(FILE2);
close(FILE3);

}

file_handling();