Combining 2 referenced arrays in perl -
hi have have function returns reference array so:
sub get_values{ . . . return(\@array) }
i re-create array :
@my_val = &get_values(...);
the dumper output of like:
$var1 = [ '1','2',...]
now need combine 2 of these, when
@combined = (@my_val,@my_val_2);
i
$var1 = [ '1','2',...] $var2 = [ '11','22',...]
i need combine in 1 element like:
$var1 = [ '1','2',...,'11','22',...]
how can this?
if function returning reference, prepared take reference, either dereferencing returning value,
my @my_val = @{ get_values(...) }; .. @combined = (@my_val, @my_val_2);
or storing reference plain scalar,
my $aref = get_values(...); .. @combined = (@$aref, @$aref2);
arrays perl pass-by-reference
No comments:
Post a Comment