I am trying to reference a two dimensional array in a
subroutine and can't seem to figure this one out in Perl.
Does anybody know? Please enlighten me.
#!/usr/bin/perl -w
use constant DIM => 4;
sub Shift_elements_right{
my (@Input, @Output) = @_;
for ($i = 0 ; $i <= DIM ; $i++ ){
$Output[$i + 1] = $Input[$i];
}
$Output[1] = $Input[DIM];
}
# Initialize
for ($i = 0; $i <= DIM; $i++){
$weight[0][$i] = $i;
}
# Shift call
for ($i = 0; $i <= DIM; $i++){
Shift_elements_right(\@weight[$i], \@weight[$i + 1]);
}
# Print output.
for ($i = 0; $i <= DIM; $i++){
for ($j = 0; $j <= DIM; $j++){
print "Weight $i : $weight[$i][$j]\t";
}
print "\n";
}