Jeff Pang schreef:

> Reference is also a scalar, when passing or returning a scalar, you
> don't need to use its reference. Passing or returning the scalar
> itself is good enough.

Yes, and that even if the sub needs to be able to change the value of
the original, because parameters are passed as aliases:

    $ perl -wle '
        sub doit { $_[0] = "dirty"; }
        my $foo = my $bar = "clean";
        print "$foo, $bar";
        doit $foo, $bar;
        print "$foo, $bar";
    '
    clean, clean
    dirty, clean

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to