in reply to Length of 2-dimensional array

-- Oops. I apparently was not clear enough, many apologies.

Here's what I have coming into a sub:
my $data = $_[0]; foreach(@$data){ #These three lines I wanted to replace $length_of_data++; }

The actual argument passed to the sub is a 2 dim array
looking like @array[dunno_how_long_this_is][2];
I need to know how many of element dunno_how_long_this_is there are
Make better sense?

The above code works fine, and is efficient enough, I just
like to use elegant Perl constructs when I'm smart enough
to figure them out
--
Felonious

Replies are listed 'Best First'.
Re: Re: Length of 2-dimensional array
by jeroenes (Priest) on Apr 06, 2001 at 10:40 UTC
    I'm sorry, but you are still not clear. Do you want the 'inner' of the 'outer' length?
    1. If you want the inner length (first dimension), just skip the sub and use
      $inner_length = @$data;
    2. If you want the outer (second) dimension, drop the sub as well: $outer_length = @{$data->[$iwannanowthalengthdude]};
    Hope this helps,

    Jeroen
    "We are not alone"(FZ)

      --
      OK - that's it. I was looking for the inner length,
      thanks.

      Ijust wasn't seeing it. I've not yet scrubbed all of this
      C from my brain yet so sometimes I get foozeld

      Silly me.

      --
      Felonious
      Fooz-eld - definition: Temporarily confused,
      frustrated. Prelude to disgruntled