# Matrice.perl # Representation de matrices # Juan Manuel Torres Moreno LIA Avignon # juan-manuel.torres@univ-avignon.fr #!/usr/bin/perl -w # Par lignes @ligne1 = (0, 1, 2); @ligne2 = (3, 4, 5); @ligne3 = (6, 7, 8); # par references @matrice = (\@ligne1, \@ligne2, \@ligne3); $ligne1_ref = [0, 1, 2]; # ou plus simplement : @matrice = ( [0, 1, 2], [3, 4, 5], [6, 7, 8], ); # afficher la ligne 1 print "$matrice[1][0] $matrice[1][1] $matrice[1][2]\n"; # afficher toute la matrice foreach $i (@matrice) { foreach $j (@{$i}) { print "$j "; } print "\n"; }