pagarwal has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: array problem
by jbrugger (Parson) on Mar 02, 2005 at 10:56 UTC
    Hello pagarwal, please read Welcome to the Monastery! Make yourself at home. and Before You Post ..., to be sure to gets some answers.
    In your 3 post's you did, you didn't use <code> tags, posted an empty question, and placed it a second time using a different title
    Basically think before post i's suggest, and read the tutorials and use supersearch before asking these basic questions.
Re: array problem
by Nevtlathiel (Friar) on Mar 02, 2005 at 11:20 UTC
    $#array_name can be used to find the length of an array, @array_name, but I'm not entirely sure how you're going to be getting at the array so I can't really be more helpful than that

    Update: As Taulmarill rightly points out this isn't strictly the length of the array, but the index of the last element, which is normally one less than the length of the array since they are zero-indexed (ie the first element of the array has index 0, not 1 as you might expect), but you might find this useful as well :)

      this is not realy true. you get the number of elements of an array by setting the array in scalar context. $#array gives you the the position of the last array element, which is mostly not the same.
      to get the size of a nested array, you have to understand references and how perl handles lists of lists. for the lazy, here is an example.

      print scalar @{$foo{key1}->[0]}, "\n";

      for those who want to know whats going on, start by reading perlreftut, perldsc and perllol.
Re: array problem
by Roy Johnson (Monsignor) on Mar 02, 2005 at 12:28 UTC
Re: array problem
by Anonymous Monk on Mar 02, 2005 at 12:47 UTC
    0 + @{$hash {Array1} [1]}
    That is, if you mean you want the length of the array that's the second element of the array on index 'Array1' of the hash. But your notation is clumsy and unformatted, so you might want something completely different.