in reply to Re: Length of multidimensional array based on the particular index value
in thread Length of multidimensional array based on the particular index value

$length++ if $_->[2] for @select;

Unfortunately, Perl doesn't understand this "double modifier" syntax (syntax error at..., near "] for "), so it would have to be:

do { $length++ if $_->[2] } for @select;

Replies are listed 'Best First'.
Re^3: Length of multidimensional array based on the particular index value
by BrowserUk (Patriarch) on Feb 24, 2011 at 10:33 UTC
    it would have to be: do { $length++ if $_->[2] } for @select;

    Can also be:

    $_->[2] and $length++ for @select;

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      And since $_->[2] is either 0 or 1 you could do:

      $length+=$_->[2] for @select;
Re^3: Length of multidimensional array based on the particular index value
by davido (Cardinal) on Feb 24, 2011 at 10:34 UTC

    there you go taking all my fun away!

    Here's an awful contortion:

    $_->[2]?length++:0 for @select;

    Dave

      $_->[2]?length++:0 for @select;

      Why are you trying to increment the length function?

      or even

      $length += !!$_->[2] for @select;

      :)

      (the !! is only required if you don't want to make assumptions that a "true" value in $_->[2] is always represented as 1)