]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/blobdiff - Plugin.pm
Introduce ->callbacks to specify the 'exec' callback individually
[perl/modules/re-engine-Plugin.git] / Plugin.pm
index ef2dbaea34c38939567c31373fb19bd94c5659ef..2177dfdacecae5948b5fe722bc5229932d4991c1 100644 (file)
--- a/Plugin.pm
+++ b/Plugin.pm
@@ -51,6 +51,19 @@ sub unimport
     return;
 }
 
+sub callbacks
+{
+    my ($re, %callback) = @_;
+
+    my %map = map { $_ => "_$_" } qw/exec/;
+
+    for my $key (keys %callback) {
+        my $name = $map{$key};
+        next unless defined $name;
+        $re->$name($callback{$key});
+    }
+}
+
 sub num_captures
 {
     my ($re, %callback) = @_;