print "$array[-1]\n"; # If you mean last element of array my $last = keys %hash; my $counter = 0; for my $key ( keys %hash ) { $counter++; print "$hash{$key}\n" if $counter == $last; } # If you mean determine if this is last item in loop