Hi, I'm wondering how reliable perl comparisons and hashes are, and if there's something I can do instead or fix. I'm using perl 5.16.1, 5.16.2, or 5.18.2.
I want to find gene names in a bed file with multiple assigned ensembl ids, and regular gene names with multiple ensembl ids. For easier reading, x with multiple z, and y with multiple z. I want to push those values into the respective arrays. These are the variables:
my %bedgenenames;
my @bedrepeats;
my %realgenenames;
my @haplotyperegionrepeats;
When I try this, I get the correct outputs for the first statement and incorrect outputs for the second.
chomp($entry);
my @array = grep {$_} split /[\t ]/, $entry;
unless(exists($bedgenenames{"$array[3]"})){
$bedgenenames{"$array[3]"}="$array[6]";
}elsif("$bedgenenames{$array[3]}" ne "array[6]"){
push @bedrepeats, "$array[3]";
print "$array[3] for $bedgenenames{$array[3]} and $array[6] bed\n"
+;
}
unless(exists($realgenenames{"$array[8]"})){
$realgenenames{"$array[8]"}="$array[6]";
}elsif("$realgenenames{$array[8]}" ne "array[6]"){
push @haplotyperegionrepeats, "$array[8]";
print "$array[8] for $realgenenames{$array[8]} and $array[6] haplo
+type\n";
}
This is the output for the first(correct, where the two ensembl ids are different) and second(incorrect, where the two ensembl ids are the same):
WASH5P14829 for ENSG00000223972 and ENSG00000227232 bed
WASH7P for ENSG00000227232 and ENSG00000227232 haplotype
How can I solve this?