use warnings; use strict; my %bow1 = (); my $file1 = shift; open (FILE1, "$file1"); # Open first file while () { my ($ID1, undef, undef, undef, $Seq1) = split; $bow1{$ID1} = $ID1; $bow1{$Seq1} = $Seq1; print STDERR "$bow1{$ID1}\t$bow1{$Seq1}\n"; } close FILE1; my %bow2 = (); my $file2 = shift; open (FILE2, "$file2"); # Open second file while () { my ($ID2, undef, undef, undef, $Seq2) = split; $bow2{$ID2} = $ID2; $bow2{$Seq2} = $Seq2; print STDERR "$bow2{$ID2}\t$bow2{$Seq2}\n"; } close FILE2; foreach my $ID1 (keys %bow1){ # can use (sort keys %hash) to put items in a specified order if ( exists $bow2{$ID2} ){ if ( $bow1{$ID1} eq $bow2{$ID2} ){ ## id and sequence are stored as key value pairs print "$bow1{$ID1} exists in $file1 and $file2 and the sequences match $bow1{$Seq1} $bow2{$Seq2} \n"; } else{ print "$bow1{$ID1} exists in $file1 and $file2 but sequences DO NOT match $bow1{$Seq1} $bow2{$Seq2} \n"; } } else { print "$bow1{$ID1} only exists in $file1 .\n"; } } exit; #### Global symbol "$ID2" requires explicit package name at /home/choia2/scripts/BowtieCompare.pl line 50. Global symbol "$ID2" requires explicit package name at /home/choia2/scripts/BowtieCompare.pl line 51. Global symbol "$Seq1" requires explicit package name at /home/choia2/scripts/BowtieCompare.pl line 53. Global symbol "$Seq2" requires explicit package name at /home/choia2/scripts/BowtieCompare.pl line 53. Global symbol "$Seq1" requires explicit package name at /home/choia2/scripts/BowtieCompare.pl line 56. Global symbol "$Seq2" requires explicit package name at /home/choia2/scripts/BowtieCompare.pl line 56. Execution of /home/choia2/scripts/BowtieCompare.pl aborted due to compilation errors.