Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Is an SV and IV or a PV or an NV or a UV? How can I tell?

by Yary (Pilgrim)
on Oct 24, 2011 at 18:44 UTC ( [id://933456]=note: print w/replies, xml ) Need Help??


in reply to Is an SV and IV or a PV or an NV or a UV? How can I tell?

How about this:
use 5.010; # just for "say" use B; ($f,$g)=(333,"xyz"); say ref B::svref_2object(\$f); say ref B::svref_2object(\$g);
edit Devel::Peek might also help you.

Replies are listed 'Best First'.
Re^2: Is an SV and IV or a PV or an NV or a UV? How can I tell?
by ikegami (Patriarch) on Oct 24, 2011 at 21:13 UTC

    This will give the answer without the superfluous "B::" prefix:

    use feature qw( say ); use B qw( ); my ($f,$g) = (333,"xyz"); say B::class(B::svref_2object(\$f)); say B::class(B::svref_2object(\$g));
    IV PV

    Note that this returns the SV *type*. It can return "PV" even if the scalar has no PV.

    use feature qw( say ); use B qw( ); $_ = 333; "".$_; $_ = undef; say B::class(B::svref_2object(\$_));
    PVIV

    This is what the OP asked, but he probably wants to know what the scalar *has*.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://933456]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-23 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found