File Coverage

blib/lib/Data/Printer/Filter/ClassicRegex.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Data::Printer::Filter::ClassicRegex;
2 1     1   25016 use warnings;
  1         2  
  1         43  
3 1     1   4 use strict;
  1         1  
  1         27  
4              
5 1     1   17839 use Data::Printer::Filter;
  0            
  0            
6              
7             our $VERSION = 0.01;
8              
9              
10             # borrowed almost verbatim from Gisle Aas' Data::Dump
11             filter 'Regexp' => sub {
12             my ($item, $p) = @_;
13             my $v = "$item";
14             my $mod = "";
15             if ($v =~ /^\(\?\^?([msix-]*):([\x00-\xFF]*)\)\z/) {
16             $mod = $1;
17             $v = $2;
18             $mod =~ s/-.*//;
19             }
20              
21             my $sep = '/';
22             my $sep_count = ($v =~ tr/\///);
23             if ($sep_count) {
24             # see if we can find a better one
25             for ('|', ',', ':', '#') {
26             my $c = eval "\$v =~ tr/\Q$_\E//"; ## no critic
27             if ($c < $sep_count) {
28             $sep = $_;
29             $sep_count = $c;
30             last if $sep_count == 0;
31             }
32             }
33             }
34             $v =~ s/\Q$sep\E/\\$sep/g;
35             return "qr$sep$v$sep$mod";
36             };
37              
38              
39             42;
40             __END__