k_manimuthu has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
Currently I am trying to get the length of the multidimensional array based on some index position. The values are Boolean. I want to count the index (x,2) value equals to ‘1’.
I got the answer for the below code. Please suggest any other smart way to get this?
Thanks@select = ( ['AAA','A Description',1,0], ['BBB','B Description',0,0], ['CCC','C Description',0,0], ['DDD','D Description',1,0], ['EEE','E Description',1,0], ); for (my $i=0; $i<@select; $i++) { $length++ if($select[$i][2]); } print "\nSelective Length : ", $length; =output 3 =cut
|
|---|