The "subtle difference" is that push-ing to an array
reference was an experimental feature
(added circa-5.10 IIRC
| added with Perl 5.14, removed as of Perl 5.24)
that is now removed. For this reason, I would avoid
it even if your particular version of Perl still supports it.
(Update: If you intend ever to publish your module,
I would absolutely avoid it!)
Win8 Strawberry 5.30.3.1 (64) Sun 04/11/2021 19:15:44 C:\@Work\Perl\monks >perl use strict; use warnings; use Data::Dump qw(dd); my %attrs = qw(foo 1 bar 2);; my @products = ({ 'id' => 0, 'name' => 'Test', 'description' => 'Some test data', 'qty' => 1, 'price' => 1000, }); $attrs{'trolley'} = \@products; my $self = \%attrs; my $new_product = { qw(id 1 name Widget) }; push $self->{'trolley'}, $new_product; # push @{ $self->{'trolley'} }, $new_product; dd \%attrs; ^Z Experimental push on scalar is now forbidden at - line 22, near "$new_ +product;" Execution of - aborted due to compilation errors.
Give a man a fish: <%-{-{-{-<
In reply to Re: Pushing hash ref onto array ref
by AnomalousMonk
in thread Pushing hash ref onto array ref
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |