Would somebody be so pleasant to explain why does the next thing happen? Here is the code:
#!/usr/bin/perl
use v5.14;
use warnings;
my @arr = (1, 2, 3);
sub func
{
return @arr;
}
push(&func(), 4);
say @arr;
When I try to run it, the output is Not an ARRAY reference at ...
.
I suppose that this is because &func()
evaluates not to the @arr
, but to a plain list 1, 2, 3
and 1
is treated as ARRAY
argument to the push
. Can somebody explain why does this happen, cause in the push
documentation I found nothing related to this.
Thanks in advance.