Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Looking for a function that returns status of a scalar's numeric flags

by haukex (Archbishop)
on Mar 22, 2020 at 08:25 UTC ( [id://11114539]=note: print w/replies, xml ) Need Help??


in reply to Looking for a function that returns status of a scalar's numeric flags

You could probably use use B qw/svref_2object/; my $flags = svref_2object(\$val)->FLAGS;, but Tux's Data::Peek seems to have pretty nice interface:

use warnings; use strict; use Data::Dump; use Data::Peek qw/DDump/; my $x = "2.7"; dd {DDump $x}->{FLAGS}; dd $x; # changes flags dd {DDump $x}->{FLAGS}; __END__ { IsCOW => 1, POK => 1, pPOK => 1 } 2.7 { IsCOW => 1, NOK => 1, pIOK => 1, pNOK => 1, POK => 1, pPOK => 1 }

Replies are listed 'Best First'.
Re^2: Looking for a function that returns status of a scalar's numeric flags
by syphilis (Archbishop) on Mar 23, 2020 at 03:57 UTC
    You could probably use use B qw/svref_2object/; my $flags = svref_2object(\$val)->FLAGS;

    Yes, I think that's the best one for the purpose I have in mind.
    I'm thinking of proposing a test to check that List::Util::uniqnum() doesn't alter the numeric flags of its arguments when it doesn't need to.
    My latest pull request was initially committing that very sin ... though I've since amended that PR such that uniqnum() no longer does that.
    Strikes me that a test to check for such behaviour could be useful, and since List::Util is perl core, the test should utilize core modules only.
    IIUC, that makes B the only option .... and therefore the best one ;-)

    It's certainly handy to be aware of other candidates - and thank you for drawing my attention to Data::Peek.
    I agree that it has a rather nice interface.

    Cheers,
    Rob

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found