> On Thu, 30 Sep 2004, Graeme McLaren wrote:
> 
> >  Can anyone tell me what the difference between @_ and shift is?
> 

<snip>

> So. In the context of subroutine arguments, you're generally passing in 
> one or more arguments. If you're only passing one, then you're right --
> 
>    my $arg = @_;

DANGER, DANGER.... the above takes a list in scalar context, $arg is now
'1', not the value of the first argument.  Throw in some parens to fix
that guy....

my ($arg) = @_;

>    my $arg = shift;
>    my $arg = $_;
> 
> -- are all equivalent. If, on the other hand, you have multiple args, 
> then these will all do different things. 
> 

<snip>

> 
> -- 
> Chris Devers
> 

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to