Hi Shlomi,
 
> Because the lack of parenthesis signifies that the right-hand-side
will
> be
> done in scalar context. As a result it is equivalent to:
> 
> my $var1 = scalar(@_);
> 
> Which is the length of the @_ array (which sometimes have some valid
> uses if
> you're checking for optional arguments but otherwise not what you want
> here.).
> 
> If you do:
> 
> my ($var1) = @_;
> 
> You're doing list assignment and, as a result, you assign $var1 to the
> $_[0]
> and don't make use of $_[1], $_[2], $_[3], etc., which may or may not
> exist.

Thanks, perfectly clear now.


> > In 'perldoc perlsub' I read that I only have to use
> > parentheses when defining more than one variable.
> 
> Where do you see that written?

Gnah, it was in the "local" section ... And it does NOT say "... ONLY
when more than one ...". Apologies for that. Note to self: Make checkup
appointment with optician. 

Regards,
Nora


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to