Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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

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 wandering the Monastery: (5)
As of 2016-10-01 18:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (3 votes). Check out past polls.