Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How do I find the size of each row of a growing multidimensional array?

by mlh2003 (Scribe)
on Mar 03, 2005 at 23:36 UTC ( #436404=note: print w/replies, xml ) Need Help??


in reply to How do I find the size of each row of a growing multidimensional array?

When you say you want to find the number of columns in each row, do you mean that you (can) have a different number of columns in each row? As Zed_Lopez mentioned, if all rows are the same size, then a single equality on the first row is all that is needed. Otherwise you'd need to loop through the array and extract the number of columns for each row. The following code again assumes you have an array of array refs:
$row = 1; foreach (@INFO_ARRAY) { print "Row $row has " . @{$INFO_ARRAY[$_]} . "columns.\n"; $row++; }
Another solution (if you wanted to retain those values) would be to populate another array with the number of elements (columns) in each row of INFO_ARRAY...
--------------------
mlh2003
  • Comment on Re: How do I find the size of each row of a growing multidimensional array?
  • Download Code

Replies are listed 'Best First'.
Re^2: How do I find the size of each row of a growing multidimensional array?
by ozgurp (Beadle) on Mar 04, 2005 at 00:09 UTC
    Sorry, I was not specific about my multidimensional array. In my case each row had same number of columns containing integers. However it is useful to know if this was not the case.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://436404]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2021-10-27 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (94 votes). Check out past polls.

    Notices?