Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Data::Types or grok_number

by tqisjim (Beadle)
on Sep 25, 2012 at 17:57 UTC ( #995606=note: print w/ replies, xml ) Need Help??


in reply to Re: Data::Types or grok_number
in thread Data::Types or grok_number

I was thinking of something along the lines of the following:

print TQIS::Primitive::typeis("1") ; > string print TQIS::Primitive::typeis(1) ; > integer
Here is the code:
#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" SV* typeis ( SV* what ) ; SV* typeis ( SV* what ) { if ( SvIOK( what ) ) return newSVpvs( "integer" ) ; else if ( SvNOK( what ) ) return newSVpvs( "double" ) ; else if ( SvPOK( what ) ) return newSVpvs( "string" ) ; return newSVpvs( "unknown" ) ; } MODULE = TQIS::Primitive PACKAGE = TQIS::Primitive PROTOTYPES: ENABLE SV* typeis( what ) SV* what


Comment on Re^2: Data::Types or grok_number
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-07-07 11:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls