in reply to Getting impossible things right (behaviour of keys)
Use a custom sort in your foreach:
becomes:foreach my $suffix (keys %sufdata)
foreach my $suffix (sort {length($b) <=> length($a)} keys %sufdata)
-Blake
In Section
Seekers of Perl Wisdom