in reply to Pushing hash ref onto array ref

Well, in my testing, for line "push $self->{'trolley'}, $new_product;", I get "experimental push on a scalar now forbidden". So I would not do that! Your second version, push @{$self->{'trolley'}}, $new_product; appears to be "the answer".

update: I was using Perl 5.24. When I see "experimental", I will "play with" the feature. But not put it into production code. In this case, even if #1 had worked, I would use #2 because the code is more clear.

Replies are listed 'Best First'.
Re^2: Pushing hash ref onto array ref
by Bod (Parson) on Apr 12, 2021 at 11:47 UTC

    I was doing my testing on the server where the code is going to be running which uses v5.16.3 which explains why you get warnings I don't.

    I should have tried it locally where I have v5.32.1 but it didn't even occur to be that there might be a versioning issue!