You don't show us what not's working. Just from glancing at the code you show, it looks like you will, in fact, build the data structure you describe (an array of references to arrays with strings in them). Note that the last fields in your arrays will have newlines; you don't say whether that's a problem (
chomp is the usual way to deal with this).
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
}
}
No reason to replace the array, as you've already replaced the values in it. That is, unless you have references to it elsewhere, in which case you could copy it:
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;
}
}