sub get_Results() { open( NEWACC, ">ref_files/$newRefFile" ) || die "$!"; open( NEWALIGN, ">blast_files/$newBlastFile") || die "$!"; ## put list of reference accessions into a structure so we can parse it... my %refList = (); while (<$ref_filehandle>) # used instead of REFFILE { chomp; # removes newline character my $key = $_; $refList{ $key } = "$_"; } #PARSE BLAST RESULT HERE.... #read results file one line at a time my @resultLine = <$blast_filehandle>; # used instead of BLASTFILE my $alignment = {}; # reference to an empty hash my @subjects; # reference to empty array my $current_subject = "front_matter"; $alignment->{$current_subject} = ""; for (my $i = 0 ; $i/) { $current_subject = $resultLine[ $i ]; chomp ($current_subject); push (@subjects, $current_subject); $alignment->{$current_subject} = ""; } $alignment->{$current_subject} = $alignment->{$current_subject}.$resultLine[ $i ]; } my @elements; foreach my $z (@subjects) { chomp $z; @elements = split('\|', $z); if ( ! defined $elements[ 3 ] ) { print ("Parsing Error
"); print ("Line $z"); } ##### PROBLEM LIES HERE WITH IF STATEMENT if (defined $elements[3] && defined $refList{$elements[3]} ) { print ("Already Present in file"); } else { print "No match in reference file"; print (NEWALIGN $alignment->{$z}."\n"); print (NEWACC $elements[3]."\n"); } } #close files close NEWALIGN; close NEWACC; }