#!/usr/bin/perl -w use strict; use Inline C =><<'END_OF_C_CODE'; #include SV* get_date( char* str ) { char date[9]; /* the date to return (with an extra byte for the NUL) */ int index = 0; /* index of character in string */ /* note the lack of error checking. I have a guaranteed date format (in generated test data). You wouldn't do this in the real world. */ while ( str[index++] != '|' ); strncpy( date, &str[index], 8); return newSVpv( date, 8 ); } END_OF_C_CODE