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
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
ten 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 A
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
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
r 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
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 com