I'm not going to go into much detail here; I've knocked up a lil example application to show where I'm having trouble; I'd like to know why $REF_DREF_A != $REF_DREF_B (and equally why there isn't a "hippo" qualifier to the "hello" in @DREF_B)...
But more importantly, can I easily make them the same, without wrapping "the array" in an object? I want to dereference the array (and still use it like an array), not clone it.
INPUT:
#!/usr/bin/perl
my(@array) = ();
push(@array,"hello");
my($REF_A) = \@array;
my($REF_B) = \@array;
print "contents of source array:\n\n";
print @array;
print "\n\nreferences to the source array:\n\n";
print "A: ".$REF_A." B: ".$REF_B;
my(@DREF_A) = @$REF_A;
my(@DREF_B) = @$REF_B;
push(@DREF_A,"hippos");
print "\n\ncontents of A dereferenced source array:\n\n";
print @DREF_A;
print "\n\ncontents of B dereferenced source array:\n\n";
print @DREF_B;
my($REF_DREF_A) = \@DREF_A;
my($REF_DREF_B) = \@DREF_B;
print "\n\nre-references to the source array:\n\n";
print "A: ".$REF_DREF_A." B: ".$REF_DREF_B;
print "\n\n";
OUTPUT:
contents of source array:
hello
references to the source array:
A: ARRAY(0x35fb0) B: ARRAY(0x35fb0)
contents of A dereferenced source array:
hellohippos
contents of B dereferenced source array:
hello
re-references to the source array:
A: ARRAY(0x1831e90) B: ARRAY(0x1831ec0)
Press any key to continue . . .