Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: breaking open a scalar with unpack P

by ikegami (Pope)
on Dec 22, 2010 at 23:34 UTC ( #878689=note: print w/replies, xml ) Need Help??


in reply to breaking open a scalar with unpack P

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://878689]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2017-12-13 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (371 votes). Check out past polls.

    Notices?