What I am after:
changes to one forces changes to other but could not make work
What I ended up with that works:
@{$this->{"pkg_variable2"}} = @{$this->{"pkg_variable1"}}
Sample listing of my problem follows.
use PkgA;
$pkga = "PkgA";
my $this = new $pkga;
print @{$this->{"pkg_variable1"}}; # this prints array of HASH values
$this->sub1();
package PkgA;
sub1 {
my $this = shift;
print @{$this->{"pkg_variable1"}}; # this prints contents of array
}
On Tue, 23 Jul 2002 05:11:52 -0500,
[EMAIL PROTECTED] (David T-G) wrote:
>Chris --
>
>...and then chris said...
>%
>% I have two variables (@array1 and @array2). @array1 will be
>% initialized with a list of values. Is it possible to declare @array2
>% in such a way that it will reference @array1?
>
>Do you want @array2 to be a *copy* of @array1 when this is all done, or
>should it actually reference @array1 so that changes to "one of them"
>force changes is "the other"?
>
>You've seen how to make a reference (the *array2 thing). If you want an
>identical but unique copy, something like
>
> bash-2.05a$ perl -e '
> @a1 = qw ( some values here ) ;
> @a2 = @a1 ;
> print "a1: $a1[1] a2: $a2[1]\n" ;
> $a2[1] = "other" ;
> print "a1: $a1[1] a2: $a2[1]\n" ;
> '
> a1: values a2: values
> a1: values a2: other
>
>might do you nicely.
>
>
>%
>% I am trying to avoid looping through the elements and copying over.
>
>That's easy; just set @a2 = @a1 and you have a copy. No loop-writing
>necessary :-)
>
>
>HTH & HAND
>
>:-D
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]