What does $#vvv--; do to a hash in Perl?

arrays, hash, key, perl

Solution

$#vvv-- looks like a comment. What's happening is the hash, being an even numbered element array, is just being reverse. So it goes from:

%vvv = (
    1 => 2,
    3 => 4,
    5 => 6
);

to:

%vvv = (
    6 => 5,
    4 => 3,
    2 => 1
);

So when the keys are printed, it grabs 642, or the new, current keys of the hash.

Problem

This is the whole script, that for some mysterious to me reason outputs "642" ``` #!usr/bin/perl %vvv = (1,2,3,4,5,6); $#vvv--; %vvv = reverse %vvv; print keys %vvv, "\n"; ``` Also what does "keys" in the last statement do? Thanks for your time. I am just on hurry I don't have proper time to do my research. So again I appreciate you input.

Original source