it magically works after converting the C-style loops to Perl
Update: ... and strip the attempt at array initialization. I was wondering why the loops were having an effect but failed to notice I automatically fixed the array init. Ups.
Output:#!/usr/bin/perl use strict; use warnings; print " Enter dimension : "; my $n = <STDIN>; $n--; my $k = 1; my @matrix; for my $i (0..$n) { for my $j (0..$n) { $matrix[$i][$j]= $k++; } } print " the matrix : \n\n"; for my $i (0..$n) { for my $j (0..$n) { print "$matrix[$i][$j] "; } print "\n"; }
% perl matrix.pl Enter dimension : 5 the matrix : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
In reply to Re: Multidimentioal array
by Monk::Thomas
in thread Multidimentioal array
by Subhrangshu Das
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |