in reply to Last Element of Hash

Here's a rather silly Other Way To Do It. Look, ma, no temporary array:
my $last = (keys %hash)[-1]; foreach my $element (keys %$hash) { if ($element eq $last) { #do this } else { #do that } }

I just added this as just something to play with. I don't think I'd ever use it in production code myself.