There are lots of ways to do this, but this is an easy one to understand...
Calling_sub($var1, $var2); sub Calling_sub { my ($subvar1, $subvar2) = @_; print $subvar1; print $subvar2; } Explaination - When you call a sub the parameters are passed via a special array named @_. Perl puts the values in here everytime you call a subroutine so that you can get to them. How you get the individual values out of the array is up to you... the syntax above is one of those ways. It is taking the two values in @_ and *copying* them to $subvar1 and $subvar2. Extra info - Remember that these are all copies of the data. So the array @_ contains copies of $var1 and $var2, and $subvar1 and $subvar2 are copies of the values in @_. Passing copies is called "Passing By Value". There is also a way to "Pass By Reference" where each variable points to the same piece of data which uses an alternate syntax. Rob -----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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]