How kosher is the following code? Is it acceptable to break open a scalar like this?

It's subject to breakage between Perl versions. Why not use B? Or if your just need a debugging or learning tool, I use Devel::Peek often.

The last line is wrong, since it relies on the scalar being a certain kind of scalar.

is this documented in Perl's documentation?

Which "this"? Outside of the perl distro, there's illguts. One normally uses the macros and constants Perl provides in C, so one doesn't normally need to know the exact values.

Does printing of references to scalars always produce SCALAR(0XBABABABA)?

No.

$ perl -E'{ package Bar; use overload q{""} => sub { "Ha!" }; } say bless(\my $foo, "Foo"); say bless(\my $bar, "Bar"); ' Foo=SCALAR(0x817bce8) Ha!

References to unblessed scalars always stringify to that format.

is a reference being a dualvar documented?

I've never heard of dualvar references, much less seen one. You couldn't have an RV/IV or RV/UV dualvar as RV, IV and UV share the same field of a scalar, but it seems possible to create an RV/NV or RV/PV dualvar. No idea how Perl would handle that.


In reply to Re: breaking open a scalar with unpack P by ikegami
in thread breaking open a scalar with unpack P by patcat88

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.