I know that passing a scalar to a sub is actually passing the reference, but since I am new to perl I still did the following test:
$i = 2;
It's because your second print statement is equivalent to doing this...
my $x = $$_; print $x;
When what you want is
my $x = $_; print $$x;
In other words, the de-referencing occurs before the array subscript is evaluated.
When you add those curl-wurlies, it tells perl how to interpret the expression as you want it; it will evaluate
$_ first, and then de-reference to get the value.