Bryan R Harris wrote:

perl -wle '

     sub inc{ ++$_ for @_ }

     my @x = 1 .. 5;

     inc @x;

     print "@x";
'
2 3 4 5 6


FYI, the reason we wanted a reference was because the data set might end up
being huge.

FYI, there is no issue.


Uh, come to think of it, I'm surprised your script does what it does.  I'd
have thought that the changes made internal to inc would've stayed there
since they're not being "returned".  This bothers me a little...

It shouldn't bother you, it should make you aware that parameters in Perl are aliases, so there is no content copying happening until you code it.


perl -wle'

    my @x = 0 .. 3;
    print "@x";

    ++$_ for grep $_, @x;
    print "@x";

    ++$_ for map $_, @x;
    print "@x";
'

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to