in reply to array reference

not sure what that meant. Can you post some code to show exactly what you are attempting to do?


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^2: array reference
by ikegami (Patriarch) on Aug 22, 2007 at 15:19 UTC

    In C, resizing an array invalidates existing pointers to the array.

    int* a; a = (int*)malloc(...); int* b = a; a = (int*)realloc(a, ...); /* b now contains garbage */

    The OP was asking if the same happens in Perl.

    my @array; my $aref = \@array; push @array, ...; # Is $aref still valid? Yes.
          In C, resizing an array invalidates existing pointers to the array.

      Now that you put it that way, I understand what was being asked.

      While I can't cite which source code in core Perl it is I know I've seen how it is handled and I definitely agree with your assesment.

      Writing sample code such as you've provided solidifies it.


      Peter L. Berghold -- Unix Professional
      Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg