Programming Perl in C
Copy(src, dst, 1024, char);      // copy 1024 bytes from src to dst
Move(buf, buf + 10, 1024, char); // copy 1024 bytes down 10 bytes in buf
IO Operations
The Perl API defines wrappers around most of the stdio functions you know and 
love. These wrappers all begin with PerlIO_ and are usually followed by the name 
of the stdio function they wrap. The perlapio documentation included with Perl 
contains a complete listing the available functions and their signatures. Be aware 
that in some cases the Perl developers have  fixed  parameter ordering and function 
names while wrapping stdio functions.
The principal difference between stdio's functions and the PerlIO set is that 
stdio uses the FILE* type to represent file handles, whereas the Perl API uses 
PerlIO*. For example, to open a log file and print a line to it, you might use code 
like this:
PerlIO *fh = PerlIO_open("/tmp/my.log", "a"); // open logfile in append mode
if (!fh) croak("Unable to open /tmp/my.log"); // check that open succeeded
PerlIO_printf(fh, "Log test...\n");           // print a test line
PerlIO_close(fh);                             // close the file
Notice that the PerlIO_printf()is actually a wrapper around fprintf(). For 
printf() functionality, use PerlIO_stdoutf():
PerlIO_stdoutf("Hello world!\n");
The Perl API also provides functions for interfacing the PerlIO model with 
existing stdio systems. For example, you can translate between PerlIO* and FILE*
file handles with the PerlIO_import and PerlIO_export functions:
PerlIO *pfh;
FILE   *fh;
pfh = PerlIO_open("some.file", "r");  // open a PerlIO handle
fh  = PerlIO_export(pfh, 0);          // export to a FILE *
// ... do some stdio work with fh
PerlIO_releaseFILE(pfh, fh);          // release fh mapping to pfh
PerlIO_close(pfh);
The Perl IO API is currently under development, and it is expected that in the 
near future Perl will cut its ties to stdio entirely. At that point, only C modules that 
use the PerlIO interface will work correctly. As such, it is important to get used to 
using PerlIO now.
20
203
3






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