Below is simple Perl scrip which demonstrate the usage of multi-dimension arrays (array of arrays)
Feel free to copy and use this code ..
Continue Reading...
Feel free to copy and use this code ..
Source: cat multi-dimensional_array.pl
#!/usr/bin/perl
# Multi-dimension array by reference.
$array = ["A", "B", ["1", "2", "3", ["x", "y", "z"]]];
print "\$array->[0] == $array->[0] \n";
print "\$array->[1] == $array->[1] \n";
print "\$array->[2][1] == $array->[2][1] \n";
print "\$array->[2][2] == $array->[2][2] \n";
print "\$array->[2][3][0] == $array->[2][3][0] \n";
print "\$array->[2][3][1] == $array->[2][3][1] \n";
print "\$array->[2][3][2] == $array->[2][3][2] \n";
print " --------------------------------------- \n" ;
@array1 = (
"A", "B",
["1", "2", "3", ["x", "y", "z"]]
);
#!/usr/bin/perl
# Multi-dimension array by reference.
$array = ["A", "B", ["1", "2", "3", ["x", "y", "z"]]];
print "\$array->[0] == $array->[0] \n";
print "\$array->[1] == $array->[1] \n";
print "\$array->[2][1] == $array->[2][1] \n";
print "\$array->[2][2] == $array->[2][2] \n";
print "\$array->[2][3][0] == $array->[2][3][0] \n";
print "\$array->[2][3][1] == $array->[2][3][1] \n";
print "\$array->[2][3][2] == $array->[2][3][2] \n";
print " --------------------------------------- \n" ;
@array1 = (
"A", "B",
["1", "2", "3", ["x", "y", "z"]]
);
0 comments:
Post a Comment