Re: returning more than 1 scalar from a subroutine

2001-10-31 Thread Brett W. McCoy
On Wed, 31 Oct 2001, Roy Peters wrote: > 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. In what ways does it make it n

Re: returning more than 1 scalar from a subroutine

2001-10-31 Thread Jenda Krynicky
From: Roy Peters <[EMAIL PROTECTED]> > 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. Sorry? You th

Re: returning more than 1 scalar from a subroutine

2001-10-31 Thread Jos I. Boumans
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();

Re: returning more than 1 scalar from a subroutine

2001-10-31 Thread Jeff 'japhy' Pinyan
On Oct 31, Roy Peters said: >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. Subroutines can return any number of argumen

Re: returning more than 1 scalar from a subroutine

2001-10-31 Thread Pete Emerson
If I understand your question correctly, this will work: #!/usr/bin/perl -w use strict; my ($a, $b, $c, $one, $two, $three); $a=1; $b=2; $c=3; ($one, $two, $three)=Change($a, $b, $c); print "$one $two $three\n"; sub Change { my ($x, $y, $z)=@_; $x++; $y=0; $z=10; return ($x, $y, $z

RE: returning more than 1 scalar from a subroutine

2001-10-31 Thread Joshua Colson
sub return_scalars { $scal1 = 5; Assign values to scalars somehow $scal2 = 7; return \$scal1, \$scal2; } ($test_scalar1, $test_scalar2) = &return_scalars(); -Original Message- From: Roy Peters [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 31, 2