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
-- 
David T-G                      * It's easier to fight for one's principles
(play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
(work) [EMAIL PROTECTED]
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: msg28062/pgp00000.pgp
Description: PGP signature

Reply via email to