sub new { my $ptr= xs_new( ... ); bless \$ptr, ...; } sub DESTROY { my $self= shift(@_); xs_free( $$self ); } #### int xs_new( ... ) WHATEVER* pObj= ...; RETVAL= (int)pObj; void xs_free( self ) int self CODE: free( (void *)self );