in reply to Adding items to arrays: best approach?
You can use "push" function, to push whole list to the end of array. See this example:
# perl -e 'use Data::Dumper; my @a = qw(1 2 3); push @a, map { $_ * 2 +} qw(4 5 6); print Dumper(\@a); ' $VAR1 = [ '1', '2', '3', 8, 10, 12 ];
Now commpare your problem:
# perl -e ' my @array1 = qw(one two three); my @array2 = qw(four seven nine); my $prefix = "C:/Temp/somedir"; my @fulllist = map { "$prefix/$_" } @array1; push @fulllist, map { "$prefix/$_" } @array2; use Data::Dumper; print Dumper(\@fulllist); ' $VAR1 = [ 'C:/Temp/somedir/one', 'C:/Temp/somedir/two', 'C:/Temp/somedir/three', 'C:/Temp/somedir/four', 'C:/Temp/somedir/seven', 'C:/Temp/somedir/nine' ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Adding items to arrays: best approach?
by Anonymous Monk on May 28, 2020 at 14:13 UTC |