in reply to Rupert

You can, but, as with many things in Perl, it's not pretty. See the XS documentation (Perl.com is a good place to start). A series of articles in Perlmonth.com also describes XS in a somewhat more palatable fashion (not that that means much, though).