+=head1 SYNOPSIS
+
+In your XS file :
+
+ #include "sub_op.h"
+
+ STATIC OP *scalar_util_reftype(pTHX) {
+ dSP;
+ dMARK;
+ SV *sv = POPs;
+ if (SvMAGICAL(sv))
+ mg_get(sv);
+ if (SvROK(sv))
+ PUSHs(sv_reftype(SvRV(sv), 0));
+ else
+ PUSHs(&PL_sv_undef);
+ RETURN;
+ }
+
+ MODULE = Scalar::Util::Ops PACKAGE = Scalar::Util::Ops
+
+ BOOT:
+ {
+ sub_op_keyword k;
+ k.name = "reftype";
+ k.len = sizeof("reftype")-1;
+ k.check = 0;
+ k.pp = scalar_util_reftype;
+ sub_op_register(aTHX_ &k);
+ }
+
+In your Perl module file :
+
+ package Scalar::Util::Ops;
+
+ use strict;
+ use warnings;
+
+ our ($VERSION, @ISA);
+
+ use Sub::Op; # Before loading our own shared library
+
+ BEGIN {
+ $VERSION = '0.01';
+ require DynaLoader;
+ push @ISA, 'DynaLoader';
+ __PACKAGE__->bootstrap($VERSION);
+ }
+
+ sub import { Sub::Op::enable(reftype => scalar caller) }
+
+ sub unimport { Sub::Op::disable(reftype => scalar caller) }
+
+ 1;
+
+In your F<Makefile.PL> :
+
+ use ExtUtils::Depends;
+
+ my $ed = ExtUtils::Depends->new('Scalar::Util::Ops' => 'Sub::Op');
+
+ WriteMakefile(
+ $ed->get_makefile_vars,
+ ...
+ );
+
+=cut
+