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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.