in reply to Re^2: Help tightening up a subroutine please
in thread Help tightening up a subroutine please

Update: Bah, I should head my own advice. The second statement never gets a chance to execute.

You're looking at the statements in isolation. Look at them as a pair.

Original post: (WRONG!)

# First time next unless defined %{$matches{$fasta_id}}; # False last unless defined @{$matches{$fasta_id}{$site}}; # False # Second time next unless defined %{$matches{$fasta_id}}; # Now true!! last unless defined @{$matches{$fasta_id}{$site}};

What really happens:

# First time next unless defined %{$matches{$fasta_id}}; # False -> next last unless defined @{$matches{$fasta_id}{$site}}; # Skipped by next # Second time next unless defined %{$matches{$fasta_id}}; # Still false last unless defined @{$matches{$fasta_id}{$site}};