Programming Perl in C
There are also tests that combine one or more of the preceding tests:
if (SvNIOK(sv))      warn("sv contains a number of some type (IV, UV or NV)");
if (SvIOK(sv))       warn("sv contains an integer of some type (IV or UV)");
Getting Values
The following macros return the value stored inside the SV as the requested type. If 
necessary, they will convert the value to the requested type.
IV iv = SvIV(sv);          // get an IV from sv
UV uv = SvUV(sv);          // get a UV from sv
NV nv = SvNV(sv);          // get an NV from sv
STRLEN len;
char  *pv = SvPV(sv, len); // get a PV from sv, setting len to the
                           // length of the string
NOTE If an SV contains a nonnumeric string, then calling SvIV(),
SvUV(), or SvNV() on it will result in the value 0. To find out if an SV
contains something that will result in a valid number, use the 
looks_like_number() function.
These functions can have a side effect they may change the internal repre 
sentation of the SV. For example, after a call to SvPV(), the stringified form of the SV
will be cached inside the SV, and both SvIOK and SvPOK will return true. As a result, 
future calls to SvPV on this scalar will use the cached copy instead of doing the con 
version again. This has two implications: First, the type of an SV may change even 
if it isn't written to, and second, the memory usage of an SV may grow even if it isn't 
written to.
There is a version of SvPV that is guaranteed to produce an SV with only a string 
value, SvPV_force. The behavior is the same as SvPV, but afterward only SvPOK will 
return true and only the string value will be retained inside the SV. This function is 
necessary if you're going to be changing the string value directly with the SvPVX
macro introduced later.
17
179
9






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved