develooper Front page | perl.fwp | Postings from July 2001

Re: Sorting in-place

Thread Previous | Thread Next
From:
Abigail
Date:
July 31, 2001 12:14
Subject:
Re: Sorting in-place
Message ID:
20010731191033.12551.qmail@foad.org
On Tue, Jul 31, 2001 at 04:00:44PM +0200,  Marc A. Lehmann  wrote:
> 
> The problem comes from the fact that scalars are passed by value (good
> idea usually), and perl implements this by copying (usually a good idea as
> well).

Oh, really?

    #!/opt/perl/bin/perl -w

    sub foo {$_ [0] ++}
    $_ = 1;
    foo $_;
    print;

    __END__
    2

Perl passes by reference, not value, as is documented in "man perlsub".



Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About