in reply to Re: Why is my code producing weird output?
in thread Why is my code producing weird output?

Note that in the line for $a( sort keys %res ), the work for the sort is completed before the first value is assigned to $a. So while this might not be best practice, I do not think it is causing the problem in this case.