Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
6 user(s) are online (4 user(s) are browsing encyclopedia)

Members: 0
Guests: 6

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

XS (Perl)

XS is an interface through which a Perl program can call a C_programming_language language subroutine. The letters stand for eXternal Subroutine, or xsub, where external means external to Perl, i.e. written in some other language.

It may be desirable for a Perl program to invoke a C subroutine in order to

  • handle very CPU or memory intensive tasks
  • interface with harware or low-level system facilities
  • make use of existing C subroutine libraries
  • The Perl , the word guts suggesting the highly technical nature of the material.

    Subroutine libraries in Perl are called modules , and modules that contain xsubs are called XS modules . Perl provides a framework for developing, packaging, distributing, and installing modules. To create an XS module, a programmer

  • runs h2xs to create an empty module
  • adds the C subroutines
  • specifies the calling interfaces to the C subroutines, using a specialized glue language (also referred to as XS)
  • compiles, tests, and installs the module with make
  • Once an XS module is installed, it can be loaded into a Perl program with a use statement, like an ordinary Perl module. Once the module is loaded, the C subroutines can be called from Perl code, as if they were written in Perl.

    XS modules are not without drawbacks

  • They are difficult to write and maintain
  • The can only be installed if
  • a C compiler is available
  • the headers that the Perl interpreter was compiled against are available
  • New versions of Perl may break binary compatibility; if this happens, all XS modules must be recompiled.
  • It is also possible to write XS modules that wrap C++ code. Doing so is mostly a matter of wrestling with the module build system. Details on how to do this are given [http://www.johnkeiser.com/perl-xs-c++.html here].

    =Related Topics=

  • Perl
  • =References=

  • Jenness, Tim & Cozens, Simon (2002). Extending and Embedding Perl . Greenwich: Manning Publications Co. ISBN 1930110820
  • =External links=

  • [http://search.cpan.org/dist/perl/pod/perlguts.pod perlxs] Perl XS application programming interface
  • [http://search.cpan.org/dist/perl/pod/perlguts.pod perlxstut] Perl XS tutorial
  • [http://search.cpan.org/dist/perl/pod/perlguts.pod perlguts] Perl internal functions for those doing extensions
  • [http://search.cpan.org/dist/perl/pod/perlguts.pod perlapi] Perl API listing (autogenerated)
  • [http://world.std.com/~swmcd/steven/perl/pm/xs/intro/index.html XS Mechanics] tutorial
  • [http://www.johnkeiser.com/perl-xs-c++.html Perl and C++] building XS modules for C++