Comparing the value of one ref to another would only work if they were created to point to the same variable. Perl doesn't compare the contents of references automatically, and a simple eq won't work for anything other than a scalar.
DB<1> $ans1=42 DB<2> $ref1=\$ans1 DB<3> $ref2=\$ans1 DB<4> if ($ref1 eq $ref2) { print "match\n" } match DB<5> $ans2 = 42 DB<6> $ref2 = \$ans2 DB<7> if ($ref1 eq $ref2) { print "match\n" } DB<8> if ($$ref1 eq $$ref2) { print "match\n" } match
In reply to Re: compare two reference in perlway
by GotToBTru
in thread compare two reference in perlway
by k_manimuthu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |