note
LanX
I was meditating about advising <c>List::MoreUtils:uniq</c> as a best practice, cause I thought it prevents any stringification problems.¹<P>
Unfortunately it doesn't! :(<P>
<c>
DB<125> $a=["A"]
=> ["A"]
DB<126> $b=["B"]
=> ["B"]
DB<127> @a=($a,"$a",$b,"$b")
=> (["A"], "ARRAY(0x96cb0f0)", ["B"], "ARRAY(0x96cfd80)")
DB<128> @b= uniq @a
=> (["A"], ["B"])
</c><P>
thats quite disappointing for an XS-module ...<P>
EDIT: Well at least it preserves order...
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-708738">
<p>Cheers Rolf
</div></div><P>
¹) I should explain, the problem with using hashes for set operations is that keys are stringified, that means working with anything which isn't a string or at least a scalar comes with a risk. <P>
Practically it's not possible to safely use a ref as a key because of the resulting string is irreversible.<P>
<c>
DB<130> $h{$a}=5
=> 5
DB<131> %h
=> ("ARRAY(0x96d1f00)", 5)
</c><P>
UPDATE:<P>
improved code example...
1011256
1011379