When you say, 

Calling_Sub($var1, $var2),

Perl automatically fills in the @_ array with the list of elements you are
passing. Now subsequently, inside your subroutine, when you say:

my $subvar = @_;

what you are doing is that you are getting the scalar value of the array.
Since you are passing two parameters and the @_ array is populated with the
values of $var1 and $var2, the value that will get stored in $subvar will be
2! That is the number of elements of the array which you are storing it in
the scalar context!

Rather, try this:

my ($subvar1, $subvar2) = @_;

Now, the first element of the array will be populated to $subvar1 and second
element of the array will be populated to $subvar2.

-- Rex


-----Original Message-----
From: Batchelor, Scott [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 20, 2002 4:21 PM
To: '[EMAIL PROTECTED]'
Subject: Calling subroutines...


Hi again all.

I have a question about calling a subroutine in Perl.  Here is what I am
trying:

Calling_sub($var1, $var2);

sub calling_sub

my $subvar = @_;

my $subvar1 = $var1

my $subvar2 = $var2



Now my question is...Don't I need to somehow split the two variables that I
passed to the subroutine so that I can use them separately? 


Scott  




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to