]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/blobdiff - t/usage/basic.pm
Backported from 0.04_01
[perl/modules/re-engine-Plugin.git] / t / usage / basic.pm
diff --git a/t/usage/basic.pm b/t/usage/basic.pm
new file mode 100644 (file)
index 0000000..80add8b
--- /dev/null
@@ -0,0 +1,31 @@
+package basic;
+use strict;
+
+# Note the (), doesn't call ->import
+use re::engine::Plugin ();
+
+sub import {
+    # Populates %^H with re::engine::Plugin hooks
+    re::engine::Plugin->import(
+        exec => \&exec,
+    );
+}
+
+*unimport = \&re::engine::Plugin::unimport;
+
+sub exec
+{
+    my ($re, $str) = @_;
+
+    $re->num_captures(
+        FETCH => sub {
+            my ($re, $paren) = @_;
+
+            $str . "_" . $paren;
+        }
+    );
+
+    1;
+}
+
+1;