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 think

        getSomething( $input, $output1, $output2, $output3);

is more intuitive than

        ( $output1, $output2, $output3) = getSomething( $input);

? A C overdose I guess.

If you change the value of $_[$i] you change the value of the 
parameter ... or get "Can't modify constant item ..." :

        sub getSomething {
                my $input = $_[0];
                $_[1] = 2 * $input;
                $_[2] = 4 * $input;
                $_[3] = 8 * $input;
        }

        getSomething( 3, $x1, $x2, $x3);

        print "result : $x1, $x2, $x3";

But why would you want to do that ...

Jenda

=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
                                        --- me

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

Reply via email to