Challo World

Einfügen von Code in die Wurst.xs


 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
 #include "ppport.h"

 MODULE = Wurst          PACKAGE = Wurst
 PROTOTYPES: ENABLE

 void
 challo()
       CODE:
                printf("Challo World!n");

Und Exportieren des Symbols challo in lib/Wurst.pm


 our %EXPORT_TAGS = ( 'all' => [ qw(challo) ] );

Und ein einfaches test.pl zum Aufruf


 #! /usr/bin/perl -w
 use strict;
 use ExtUtils::testlib;
 use Wurst qw(challo);

 print "n achtung, jetzt kommt Ausgabe aus C-Code";
 challo();