]> git.vpit.fr Git - perl/modules/re-engine-Hooks.git/blob - samples/stepbystep.pl
Update VPIT::TestHelpers to 15e8aee3
[perl/modules/re-engine-Hooks.git] / samples / stepbystep.pl
1 #!perl
2
3 use 5.010;
4
5 use strict;
6 use warnings;
7
8 use blib;
9 use blib 't/re-engine-Hooks-TestDist';
10
11 use Term::ReadKey;
12
13 die "Usage: $0 regexp string1 string2...\n" unless @ARGV >= 2;
14 my ($rx, @strings) = @ARGV;
15
16 ++$|;
17
18 my $cb;
19 BEGIN {
20  $cb = sub {
21   print "executed $_[0] regnode\n";
22   Term::ReadKey::ReadMode(4);
23   my $key = Term::ReadKey::ReadKey(0);
24   Term::ReadKey::ReadMode(1);
25  }
26 }
27
28 {
29  use re::engine::Hooks::TestDist 'custom' => $cb;
30
31  $rx = qr/$rx/;
32 }
33
34 for my $str (@strings) {
35  print "Matching string \"$str\"\n";
36
37  {
38   use re::engine::Hooks::TestDist 'custom';
39   $str =~ $rx;
40  }
41 }