Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
> But your simple elegant code is relying on implicit stringification, and repeated stringification of the same values. This is inefficient if it's a complex data structure, and needs an explicit call in the general code to handle ad-hoc data structures that are not blessed into a class with a stringify operator that's suitable for this purpose.

In Perl stringification of references has no performance penalty. It's just a string with the reference addressą and the type (this includes package name if blessed).

perl -e '$p=[];print $p' ARRAY(0x928c880)

(I think you are confusing with other language like JS˛, where the whole data is dumped)

OTOH, there is a doubled memory consumption when using primitive scalars like long strings.

>As for getting a fake "" key you need to toss out, I don't think that's a problem if you make sure that the stringification never returns "" for a valid item in the set.

well I think a special case handling "" wouldn't cost too much's just not elegant anymore.

> Ultimately, I think the answer to "how do I find an intersection" isn't to repeat some incantation invented by someone else, but to simply call intersection. The algorithm should be canned in a CPAN module.

There is already Set::Object which seems to follow the same ideas, but it looks heavy and uses inline C...

Anyway my point was first to improve the FAQ and then thinking about a module.

Cheers Rolf

1) Of course one should be careful when mixing strings and references in one set... :)

2) e.g. javascript:a=[1,[2,3]];alert(a) shows 1,2,3

In reply to Re^2: Using hashes for set operations... by LanX
in thread Using hashes for set operations... by LanX

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (5)
    As of 2021-03-03 03:23 GMT
    Find Nodes?
      Voting Booth?
      My favorite kind of desktop background is:

      Results (69 votes). Check out past polls.