in reply to insert value into an array

Hi, Try this,

use strict; use warnings; use Data::Dumper; my @arr=(["one" => [1,11]], ["two"=> [2,22]]); my ($position, $value) = @ARGV; print "\nBefore:\n"; print Dumper @arr; push (@{$arr[$position]->[1]}, $value); print "\nAfter:\n"; print Dumper @arr; __END__ Before: $VAR1 = [ 'one', [ 1, 11 ] ]; $VAR2 = [ 'two', [ 2, 22 ] ]; After: $VAR1 = [ 'one', [ 1, 11 ] ]; $VAR2 = [ 'two', [ 2, 22, '222' ] ];

If you need the value as integer then use int function as push (@{$arr[$position]->[1]}, int($value));

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';