"Wiggins" == Wiggins D Anconia <[EMAIL PROTECTED]> writes:
Wiggins> Out of curiousity, why/when *in Perl* would you take a reference to Wiggins> something that holds a reference? And, "how deep does the well go?" Wiggins> (how far will Perl take the above indirection?)... I suppose I could Wiggins> just test, but I am rather 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.
A worthy answer, but isn't this just a style issue based on preference, aka maybe to make it look more like a C idiom, rather than a need (which is why I emphasized "in Perl" originally)? For instance, it seems more Perl'ish to have your function return the reference to table_one/table_two rather than calling the function in void context and passing the location of where you want the reference set, that seems very C'ish (from what little C I have seen).
In any case, was just seeing what the group could propose, thanks!
http://danconia.org
p.s. I am out for a week, don't suppose I will find a computer in Cancun, since I won't be looking!!
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>