develooper Front page | perl.beginners | Postings from April 2010

Passing arguments @_

Thread Next
From:
HACKER Nora
Date:
April 29, 2010 23:56
Subject:
Passing arguments @_
Message ID:
B0F28E896606CF4599D9B933747818BD0179A096@MAIL.stgkk.sozvers.at
Hi,

For calling subroutines and passing arguments on I use e.g.

my ( $var1, $var2 ) = @_;

If I have only one argument, this is also ok:

my ( $var1) = @_;

But why does 

my $var1 = @_;

not work? In 'perldoc perlsub' I read that I only have to use
parentheses when defining more than one variable. When using the latter
code, the value of $var1 is "1", seems to be the number of elements
passed by @_. Please enlighten me or give me a hint what keywords to
search for.

Thanks, 
Nora 




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About