On Jun 6, Nikola Janceski said:

>is there a difference between:
>
>@{ $HASH{$key} } = @array;
>$HASH{$key} = \@array;

Yes.  The first overwrites everything currently contained in the array
reference $HASH{$key}; the second merely creates a new array reference,
and binds it @array.

Watch:

  my (@foo, $bar, $blat);

  @foo = qw( this is the way );
  $bar = \@foo;
  @$blat = @foo;

  $foo[3] = 'end';

  print "@$bar\n";   # this is the end
  print "@$blat\n";  # this is the way

But watch more:

  # assuming the above...
  my @quux = qw( where is the light );

  @$bar = @quux;

  print "@foo\n";    # where is the light
  print "@$bar\n";   # where is the light
  print "@$blat\n";  # this is the way

Because $bar was linked to @foo, when we changed the ELEMENTS of $bar (we
did not make a new reference, we merely modified the contents of the
existing one), we changed the elements of @foo.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to