this code just returns a reference to a scalar, which is rather pointless in this case and really doesn't solve the problem.
> sub return_scalars { > $scal1 = 5; Assign values to scalars somehow > $scal2 = 7; > return \$scal1, \$scal2; > } > > ($test_scalar1, $test_scalar2) = &return_scalars(); you can do 2 things in this case: 1: get a list of scalars returned #which can be treated as an array by the caller 2: get a reference to a list of scalars returned. 1: sub gimme { return ( 'foo', 'bar', 'bleh' ) } 2: sub gimme { return [ 'foo', 'bar', 'bleh' ] } the benefit of 2 is that you get a scalar returned (since references are just special scalars really). you could access the element 'bar' like this: my $array_ref = gimme(); my $val = $array_ref->[1]; it's often wise to just pass around references. if you want to know more about the why and how, take a look at http://japh.nu and read the tutorial on references. hth, Jos > -----Original Message----- > From: Roy Peters [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, October 31, 2001 7:44 AM > To: [EMAIL PROTECTED] > Subject: returning more than 1 scalar from a subroutine > > > hi, > > Is there any way to return 2 or 3 scalar variables from a subroutine (like > passing a variable by reference in C)? > > I would like to avoid returning an array, if possible, because it makes > the script very non-intuitive. > > Thanks > > > -- > 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] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]