You would use the module I just posted and do something like:

$Var1 = 1234; SvNIOK($Var1);
This will return true: 1234 will create a SvIV or 16 bit number

$Var2 = "1234"; SvNIOK($Var2);
This will return false since that was the string representation of a number but not actually a number

Now check this out:

$Var2 + 0; SvNIOK($Var2)
This will now return true since now $Var2 is both a string and number. So this is why perl datatypes are pointless.

SvPOK asks whether there is a pointer or string component to the scalar. This would return true for both checks of $Val2

Josh


"Ulrich Holeschak" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]

06/10/2002 02:50 AM
Please respond to "Ulrich Holeschak"

       
        To:        <[EMAIL PROTECTED]>
        cc:        
        Subject:        Check data type?



Hello,
how can i find out the internal data representation (data type) of a perl
variable?

Example:
$Var1 = 1234;            # this is an integer
$Var2 = "1234";        # this is an string

I want to know if $VarX is internally stored as integer or as string.


Ulrich Holeschak
Bihl+Wiedemann GmbH
Flosswoerthstrasse 41
D-68199 Mannheim
Tel. +49 621/ 33996-0
Fax. +49 621/ 3392239
eMail: [EMAIL PROTECTED]
http://www.bihl-wiedemann.de


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Reply via email to