Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: searching array of arrays

by greywolf (Priest)
on Aug 02, 2001 at 20:03 UTC ( [id://101691]=note: print w/replies, xml ) Need Help??


in reply to searching array of arrays

So you have an array of arrays (2 dimensional) built with
husani|10|20 bill|1|3 john|5|2

That gives you something like @array[][]. husani is at $array[0][0] and bill is at $array[1][0]. You must loop through the first dimension while checking the appropriate index in the 2nd dimension. When the match is found you can change any element in the 2nd dimension.
for (my $x = 0; $x < @array; $x+) { if ($array[$x][0] eq 'bill') { $array[$x][1] = 45; } }

It may not be the slickest way to do it but it will work.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-24 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found