
BillKSmith
Veteran
Nov 26, 2012, 11:55 AM
Post #3 of 3
(3107 views)
|
Re: [orange] firstidx, 'array of arrays'
[In reply to]
|
Can't Post
|
|
Strictly speaking, perl does not support multi-dimensional arrays. Proper use of references largely hides this fact. In your case, the symbol @services refers to a single dimensional array. Each element of that array is a reference. Each reference refers to a list of scalars (one "row" in your notation). The data that you think of as 'column 1" consists of the second (indexes start with zero) element of each of these arrays. To treat that colulmn as a list, you must explicitly extract it.
my @col1 = map ($_->[1]) @services; my $index= firstidx { $_ eq '7' } @col1; Update: Chris Charley neatly combined these two statements into one. Good Luck, Bill
(This post was edited by BillKSmith on Nov 26, 2012, 9:16 PM)
|