There are a few ways to add (actually append in this case) one array to another, even if they are array references. A couple:
Both methods produce the same results. I prefer the method using push: it's more familiar and readable IMHO, possibly a bit faster. In both cases, a shallow copy of the appended array is done.Win8 Strawberry 5.8.9.5 (32) Mon 09/20/2021 15:47:19 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings use Data::Dumper; my $ar_1 = [ qw(knights who say ni) ]; my $ar_2 = [ qw(foo bar baz quux) ]; # push @$ar_1, @$ar_2; $ar_1 = [ @$ar_1, @$ar_2 ]; print Dumper $ar_1; ^Z $VAR1 = [ 'knights', 'who', 'say', 'ni', 'foo', 'bar', 'baz', 'quux' ];
Give a man a fish: <%-{-{-{-<
In reply to Re^3: Adding only searched values to array ref
by AnomalousMonk
in thread Adding only searched values to array ref
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |