Actually for references '==' is comparing for the same instance (referential equality). For recent enough perls the smartmatch ~~ operator can do at least a first level check for structural or object equality. If you want to compare if they more deeply nested structures contain the same contents you need do more work; see the FAQ "How do I test whether two arrays or hashes are equal?".
$ perl -MTest::More -dE 0 [...] DB<1> $a = { qw/a 1 b 2/ } DB<2> $b = { qw/a 1 b 2/ } DB<3> x $a 0 HASH(0x7f9140905ad0) 'a' => 1 'b' => 2 DB<4> x $b 0 HASH(0x7f914090b698) 'a' => 1 'b' => 2 DB<5> x $a == $b 0 '' DB<6> x is_deeply( $a, $b ) ok 1 0 1 DB<7> x is_deeply( $a, {} ) not ok 2 # Failed test at /Users/nbkawb9/perl5/lib/perl5/Test/Builder.pm line + 152. # Structures begin differing at: # $got->{a} = '1' # $expected->{a} = Does not exist 0 0 DB<8> q
Additionally: For real fun check out Lisp which has several predicates for different amounts of equality.
Edit: Tweaked slightly ambiguous "they" to more explicit wording.
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: Python 'is' command
by Fletch
in thread Python 'is' command
by betmatt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |