Multidimentional Array Example in PERL

Multidimentional Array Example in PERL

create a file named "perl-tutorial-example-multidimentional-array-in-perl.pl" then copy and paste the below code:

print "\n\n";
print "Multidimensonal Array Example in PERL";
print "\n";
print "---------------------------------------";

@MultidimensonalArray=
(
   [ 'abc' , 'xyz', 'mnp' ],
   [ 1, 2, 3 ],
   [ aa, bb, cc ],
   [ 22, 33, 44 ]
);

print "\n\n";
print @MultidimensonalArray;
print "\n\n";
print $MultidimensonalArray[0][1], " ", $MultidimensonalArray[1][1];

print "\n\n";
print "Complete Array";
print "\n";
print "-------------";
print "\n";
for($a=0; $a < 4; $a++)
{
   for($b=0; $b < 3; $b++)
   {
      print $MultidimensonalArray[$a][$b]," ";
   }
   print "\n";
}
print "-------------";
print "\n\n";

Unix wc -l Equivalent DOS Command Using C Program

Now compile run the program(perl-tutorial-example-multidimentional-array-in-perl.pl) from command prompt & get some interesting results as follows:

Multidimentional Array Example in PERL - output in the windows command prompt

The result in the windows command prompt

No comments:

Post a Comment

leave your comments here..