in reply to Can someone clarify what's happening here

If you use warnings, you'll have your answer. See use strict and warnings.
  • Comment on Re: Can someone clarify what's happening here

Replies are listed 'Best First'.
Re^2: Can someone clarify what's happening here
by duranain (Initiate) on Aug 11, 2010 at 02:03 UTC
    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)
      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.