Programming Perl in C
// print out the returned counts, in reverse order
for(i = num; i > 0; i++) {
  printf("count %d: %d\n", i, SvIV(POPs));
}
FREETMPS; LEAVE;                        // end the scope   freeing mortal
                                        // variables
There are two new pieces in this example. First, the call is made using the G_ARRAY
option indicating that I expect to get a list of return values back. Also, the return 
value from call_pv(), the number of values returned on the stack, is saved. Then a 
loop is run that prints out the values in reverse order. A more elaborate loop could 
be written to process the return values in the  correct  order, but since POPs works 
in reverse, it's easiest to follow suit.
Signaling Errors
There are two ways to return from a Perl subroutine by using return() or by gen 
erating an exception with die(). The interface to die() from the C API is croak(),
which supports a printf() style interface for generating exception strings:
croak("Big trouble, Indy, the %s has got the %s!", villain, bauble);
A warning, provided by the warn() function in Perl, can be produced using the 
warn() API function:
warn("Ouch, don t touch that, %s!", SvPVX(name_sv));
This is an unconditional warning it will always generate output no matter what 
the state of the warnings pragma. If you want to check whether warnings are on or 
not, you can use the isLEXWARN_on macro:
7
if (isLEXWARN_on) warn("You use warnings; good for you!");
You can also test if a particular category of warnings is on using the ckWARN macro:
8
if (ckWARN(WARN_DEPRECATED)) warn("Use of this function is deprecated.");
The constants used by this macro are lists in the warnings.h file in the Perl source.
7. Which isn't listed in perlapi and as such may change without notice
8. Also not listed in perlapi beware!
20
201
1






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