#include #include char *hello(void) { static char result[]={"hello world"}; return result; } char *bye(char *str) { static char prefix[]={"good bye"}; static char result[32]; strcpy(result,prefix); strcat(result,str); return result; } char *return_char(int chr) { static char result[1]; sprintf(result, "%c", chr); return result; } int square(int x) { x = (x * x); return x; } int do_nothing(void) { return 1; } #### #!/usr/bin/perl use P5NCI::Library; my $lib = P5NCI::Library->new( library => 'hello_world', package => 'TEST' ); my $test = $lib->install_function( 'hello', 'tv' ); my $hello = TEST::hello(); print "for hello() i got: $hello\n"; undef $test; my $test = $lib->install_function( 'return_char', 'ti' ); my $return_char = TEST::return_char( 65 ); print "for return_char(65) i got: $return_char\n"; undef $test; my $test = $lib->install_function( 'square', 'ii' ); my $square = TEST::square( 3 ); print "for square(3) i got: $square\n"; undef $test; my $test = $lib->install_function( 'bye', 'tt' ); my $bye = TEST::bye( "thanks for all the passwords" ); print "for bye(test) i got: $bye\n"; undef $test; my $test = $lib->install_function( 'do_nothing', 'vi' ); my $do_nothing = TEST::do_nothing(); print "for do_nothing() i got: $do_nothing\n"; undef $test;