in reply to searching array of arrays
You also don't say why you're building the whole data structure in memory before doing the search (are you?) rather than searching on the fly as the data comes in. But assuming that's what you have to do for some reason, you can just iterate through your array:
for my $a (@foo) { if ($a->[0] eq 'bill') { $a->[1] += 3; # add 3 to second field $a->[2] .= "!"; # add ! to third field } }
for my $i (0 .. $#foo) { my $a = $foo[$i]; if ($a->[0] eq 'bill') { my $b = [ @$a ]; # copy a's data to b $b->[1] += 3; # add 3 to second field $b->[2] .= "!"; # add ! to third field $foo[$i] = $b; } }
|
|---|