Hmm, I have almost never used the smart match operator. For a very long time, I could not use it because I could not upgrade to a Perl version supporting it. By the time I could finally upgrade, the smart match operator had become deprecated (or, rather, labeled, experimental and subject to changes), so that I prefer not to use it, and you should probably do the same.

Having said that, and keeping in mind that I've never used smart match for anything but just quickly testing it out of curiosity, I would think that comparing an array with an hash ref (i.e. a scalar containing a reference to an hash) is probably unlikely to work. Maybe you would need to dereference the hashref before using it. But I may be completely wrong on that. An additional consideration is that your hash or hashref should be declared before entering the foreach loop.

Anyway, given the experimental nature of the smart match, using a hash or a hash of hashes (depending on what type of uniqueness you exactly need) in the traditional idiomatic Perl way is likely to be a more robust and lasting solution.


In reply to Re: Removing duplicate hashrefs from an array by Laurent_R
in thread Removing duplicate hashrefs from an array by msomanat

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.