Devel::Peek confirms the difference:

use Devel::Peek; #...etc... bless $x{foo}, 'Null'; print Dump( $y ); print Dump( $x{foo} );

$y has FLAGS = (PADBUSY,PADMY,ROK) and $x{foo} has FLAGS = (ROK,OVERLOAD).

Fuller output:

SV = RV(0x1822a6c) at 0x181c38c # $y REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x18014a0 SV = PVHV(0x1821f90) at 0x18014a0 REFCNT = 2 FLAGS = (OBJECT,SHAREKEYS) IV = 1 NV = 0 STASH = 0x180b584 "Null" ARRAY = 0x301120 (0:7, 1:1) hash quality = 100.0% KEYS = 1 FILL = 1 MAX = 7 RITER = -1 EITER = 0x0 Elt "a" HASH = 0xca2e9442 SV = PV(0x1801678) at 0x181c4dc REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x301110 "b"\0 CUR = 1 LEN = 2 SV = RV(0x1822a74) at 0x181c4f4 # $x{foo} REFCNT = 1 FLAGS = (ROK,OVERLOAD) RV = 0x18014a0 SV = PVHV(0x1821f90) at 0x18014a0 REFCNT = 2 FLAGS = (OBJECT,SHAREKEYS) IV = 1 NV = 0 STASH = 0x180b584 "Null" ARRAY = 0x301120 (0:7, 1:1) hash quality = 100.0% KEYS = 1 FILL = 1 MAX = 7 RITER = -1 EITER = 0x0 Elt "a" HASH = 0xca2e9442 SV = PV(0x1801678) at 0x181c4dc REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x301110 "b"\0 CUR = 1 LEN = 2

I notice that the OVERLOAD flag is on the scalar itself rather than the reference it's holding. The reference knows that its an object but not that it's overloaded. I guess to get $y to be overloaded, you'd have to rebless it directly. That said, given a reference, I don't know how you'd find other scalars that have the reference.

Update: See also Is it possible to obtain all hardreferences to some memory address by knowing only one of them?


In reply to Re: Overload + reblessing oddity by kyle
in thread Overload + reblessing oddity by dragonchild

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.