in reply to Re: adding elements to already exisiting elements in an array
in thread adding elements to already exisiting elements in an array

if ( ref( $Elements[$1] ) eq "ARRAY" ) { push ( @{$Elements[$l]} }, $value ); } else { $Elements[$1] = [$value]; }

Note that you do not need to test whether you already have an array ref. as Perl will auto-vivify an anonymous array for you.

$ perl -MData::Dumper -e' > @arr = (1, 2); > push @{ $arr[2] }, 3, 4; > push @arr, 5; > print Data::Dumper->Dump([\ @arr], [q{*arr}]);' @arr = ( 1, 2, [ 3, 4 ], 5 ); $

Note also that samtregar's comments are above yours, you may have your monitor upside down :-)

Cheers,

JohnGG