#!/usr/bin/env perl use ExtUtils::testlib; use Data::Dumper; use myClibs; print "Compiling C program...\n"; print qx{compile.sh}; my $test = [ 1, 2, 3, 4, 5, 6, 9]; ArrayTest::print_array_char( "revendar" ); print "------------------------------------------------\n"; ArrayTest::print_array_char( @$test ); print "------------------------------------------------\n"; ArrayTest::print_array_int( "revendar",8 ); print "------------------------------------------------\n"; ArrayTest::print_array_int( @$test ,8 ); #### #include #include #include void print_array_char(char * array) { int l; int i; l=strlen(array); printf("Length of array is %d\n",l); for(i=0;i < l;i++) { printf("Element array[%d] = %c\n",i,array[i]); } } void print_array_int(const int array[], int l) { int i; for(i=0;i < l;i++) { printf("Element array[%d] = %d\n",i,array[i]); } } #### #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" MODULE = myClibs PACKAGE = ArrayTest PROTOTYPES: ENABLE #include #include #include void print_array_char(array) char * array void print_array_int(array,l) char * array int l #### package myClibs; our $VERSION = '0.01'; require XSLoader; XSLoader::load('myClibs', $VERSION); 1;