Adam wrote:
I am expecting in both examples the same result:
Example1: the same references
Example2: the same references
However, I get:
Example1: different references
Example2: the same references
What am I missing?
#Example1
my $r1 = [1, 3];
Store a reference to an anonymous array in a scalar.
my $r2 = [1, 3];
Store a reference to a different anonymous array in a scalar.
if ($r1 eq $r2) {
$r1 and $r2 point to different arrays.
print "Example1: the same references\n";
}
else{
print "Example1: different references\n";
}
#Example2
my @a1 = (1, 3);
Store a list to a named array.
my $r3 = [EMAIL PROTECTED];
Store a reference to the named array in a scalar.
my $r4 = [EMAIL PROTECTED];
Store a reference to the same named array in a scalar.
if ($r3 eq $r4) {
$r3 and $r4 point to the same named array.
print "Example2: the same references\n";
}
else{
print "Example1: different references\n";
}
perldoc perlreftut
perldoc perlref
perldoc perldsc
perldoc perllol
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>