http://qs321.pair.com?node_id=375395


in reply to Re^2: Aliasing values, not variables
in thread Aliasing values, not variables

It may well be that my solution misses the goal. As far as I understood it, nothingmuch wants two slots in an array to contain the same scalar, and I believe that my subroutine alias does that.

The routine returns a reference to an array in which the elements are aliased as passed in. So to create an array which aliases the slots 2,3 and 4, you would call it as:

my $v; my $ar = alias("foo","bar",$v,$v,$v,"baz");

Assigning to any of the slots 2,3,4 of @$ar will change the other two slots as well, which is how I interpret the question.

I might well have misunderstood the question and the problem, as I also don't understand what he needs it for, or rather, what he needs it for prompts different solutions to me.

Replies are listed 'Best First'.
Re^4: Aliasing values, not variables
by japhy (Canon) on Jul 18, 2004 at 16:43 UTC
    You're right. I didn't pay attention to what your function was doing. Your solution can be expanded to work with existing aggregates in a general way.
    _____________________________________________________
    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart