You can only ever push onto an array.
push @{ $config->{groups}->{$last_group} }, $line;
could have been written as
my $ref_to_array = $config->{groups}->{$last_group} push @$ref_to_array, $line;
if that helps.
Some reference material:
perlref
perllol
References Quick Reference
Dereferencing Syntax
Update: Oops, those two snippets aren't the same due to autovivification.
my $ref_to_array = $config->{groups}->{$last_group} push @$ref_to_array, $line; # In case $ref_to_array was autovivified, $config->{groups}->{$last_group} = $ref_to_array;
Or vivify it explicity,
my $ref_to_array = $config->{groups}->{$last_group} ||= []; push @$ref_to_array, $line;
That kind of confuses the point, which was that the expression within the curlies returns an array reference, which is derefenced by @{}, resulting an array being passed to push.
In reply to Re: PUSH Question
by ikegami
in thread PUSH Question
by emusic32
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |