in reply to Re: Can someone clarify what's happening here
in thread Can someone clarify what's happening here

use strict causes it to whinge that i'm not using my to declare @perls, but if that's fixed, the code still exhibits the same behavior (@{shift()} works, @{shift} does not)
  • Comment on Re^2: Can someone clarify what's happening here

Replies are listed 'Best First'.
Re^3: Can someone clarify what's happening here
by ikegami (Patriarch) on Aug 11, 2010 at 02:20 UTC
    Did you forgot to remove the parens? You should have gotten a warning and a strict error, but of which explain the issue.
    use strict; use warnings; my @perls = (1, 2, 3, 4); sub foo { my @foo = @{shift}; return join $/, @foo } print foo(\@perls)
    Ambiguous use of @{shift} resolved to @shift at a.pl line 7. Global symbol "@shift" requires explicit package name at a.pl line 7. Execution of a.pl aborted due to compilation errors.