> -----Original Message----- > From: Randal L. Schwartz [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 24, 2003 3:50 PM > To: [EMAIL PROTECTED] > Subject: Re: the ref() function: what does it mean when ... > > > >>>>> "Wiggins" == Wiggins D Anconia <[EMAIL PROTECTED]> writes: > > Wiggins> Out of curiousity, why/when *in Perl* would you take a > Wiggins> reference to something that holds a reference? And, > "how deep > Wiggins> does the well go?" (how far will Perl take the above > Wiggins> indirection?)... I suppose I could just test, but I > am rather > Wiggins> lazy... > > For the same reason you might take a reference to a scalar > otherwise... indirection. > > For example, I might have > > my $active_table = [EMAIL PROTECTED]; > > and then I want to call a subroutine to decide a new active table: > > adjust_table(\$active_table); > > sub adjust_table { > my $table_ref = shift; > $$table_ref = rand(2) > 1 ? [EMAIL PROTECTED] : [EMAIL PROTECTED]; > } > > I can't change $active_table except by reference. >
My question would be, why force the reference issue at all when you could do something like: my $active_table = [EMAIL PROTECTED]; $active_table=adjust_table(); sub adjust_table { return(rand(2) > 1 ? [EMAIL PROTECTED] : [EMAIL PROTECTED]); } Shawn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>