As you can see the $rr contains the reference to the first element of the array , now as the definition say array contains the continuous memory location, so when I incremented the $rr with 1 so it should now print the value for $array[1]..
Please correct me if I am wrong.
---------- Post updated at 04:52 AM ---------- Previous update was at 03:02 AM ----------
You cannot do $rr++ in perl like the way you can in C.
Perl offers a different way of accessing the subsequent elements of an array through reference variables. If you didn't already know this, take a look at the sample below:
For e.g.,
#! /usr/bin/perl -w
use strict;
my @array = (10, 20);
my $rarray = \@array;
print "@{ $rarray }[0]\n";
print "@{ $rarray }[1]\n";
All three options are different ways that perl offers you to access the same element. Remember, with perl, its always TMTOWTDI. You adopt the style that you're comfortable with.