blib/lib/DBI/ProfileSubs.pm

filter: Statementstmt 94.1% 16 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 90.4% 19 / 21 CC 1 SCAR 0.0
CC
1
Cov
94%
norm_std_n3
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« DBI.xs ↑ Summary blib/lib/DBD/Gofer/Policy/classic.pm »
1 package DBI::ProfileSubs;
2  
3 2 our $VERSION = "0.009396";
4  
5 =head1 NAME
6  
7 DBI::ProfileSubs - Subroutines for dynamic profile Path
8  
9 =head1 SYNOPSIS
10  
11 DBI_PROFILE='&norm_std_n3' prog.pl
12  
13 This is new and still experimental.
14  
15 =head1 TO DO
16  
17 Define come kind of naming convention for the subs.
18  
19 =cut
20  
21 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24  
25 # would be good to refactor these regex into separate subs and find some
26 # way to compose them in various combinations into multiple subs.
27 # Perhaps via AUTOLOAD where \&auto_X_Y_Z creates a sub that does X, Y, and Z.
28 # The final subs always need to be very fast.
29 #
30  
31 8 ▶sub norm_std_n3 {
Subroutine norm_std_n3: called CC=1 SCAR=0.0
Pod undocumented
32 # my ($h, $method_name) = @_;
33 8 local $_ = $_;
34  
35 8 s/\b\d+\b/<N>/g; # 42 -> <N>
36 8 s/\b0x[0-9A-Fa-f]+\b/<N>/g; # 0xFE -> <N>
37  
38 8 s/'.*?'/'<S>'/g; # single quoted strings (doesn't handle escapes)
39 8 s/".*?"/"<S>"/g; # double quoted strings (doesn't handle escapes)
40  
41 # convert names like log20001231 into log<N>
42 8 s/([a-z_]+)(\d{3,})\b/${1}<N>/ig;
43  
44 # abbreviate massive "in (...)" statements and similar
45 0 s!((\s*<[NS]>\s*,\s*){100,})!sprintf("$2,<repeated %d times>",length($1)/2)!eg;
46  
47 8 return $_;
48 }
49  
50 2 1;
« DBI.xs ↑ Summary blib/lib/DBD/Gofer/Policy/classic.pm »