princepawn has asked for the wisdom of the Perl Monks concerning the following question:
my $count = 1; sub modify { my $aref = $_[0]; ${$aref->[1]}=$count++; } sub prelayer { my $aref = shift; modify $aref; } my ($x, $mod) = (666,777); my @A = \($x, $mod); prelayer \@A; print $mod, $/; prelayer [ \$x, \$mod ]; print $mod, $/;
I was wondering if something like this would work:
if I could create some sort of special magic in the called subroutines. I would like for the calling syntax to be as clean as possible and do all the dirty work in my subroutines.prelayer([ $x, $mod ]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing an array ref to subroutine and modifying its elements
by chromatic (Archbishop) on Apr 07, 2001 at 03:59 UTC | |
|
Re (tilly) 1: passing an array ref to subroutine and modifying its elements
by tilly (Archbishop) on Apr 07, 2001 at 05:33 UTC | |
|
(tye)Re: passing an array ref to subroutine and modifying its elements
by tye (Sage) on Apr 07, 2001 at 10:23 UTC |