in reply to insert value into an array
sub alist_get { my $k = shift; for (@_) { return $_ if $_->[0] eq $k } die "No such key in alist: $k" } push @{alist_get('two', @arr)->[1]}, 222;
Incidentally, => works just like a comma, except that it stringifies its LHS. It's not hash-related magic. So, you could define your array thus:
my @a = ([one => [1,11]], [two => [2,22]]);And likewise I could've invoked my subroutine as alist_get(two => @arr) -- Neat, huh?
/assumes you have a good reason to not use a hash. :-)
|
|---|