File Coverage

blib/lib/PDL/NiceSlice/FilterUtilCall.pm
Criterion Covered Total %
statement 27 29 93.1
branch 9 12 75.0
condition 1 3 33.3
subroutine 4 4 100.0
pod n/a
total 41 48 85.4


line stmt bran cond sub pod time code
1             # This original Filter::Util::Call-based
2             # PDL::NiceSlice engine.
3             #
4 122     122   70006 use Filter::Util::Call;
  122         116577  
  122         45087  
5              
6             ##############################
7             # If you mess with the import filter, please also change the pdlpp importer
8             # just above this comment! They both do similar things, but one to an eval string
9             # and one to an import file.
10             # --CED 5-Nov-2007
11             #
12             sub import {
13 128     128   1890 my ($class) = @_;
14 128         685 ($file,$offset) = (caller)[1,2]; # for error reporting
15 128         503 $offset++;
16            
17             ## Parse class name into a regexp suitable for filtration
18 128         505 my $terminator = terminator_regexp($class);
19              
20             filter_add(
21             sub {
22 255     255   67537 my ($status, $off, $end);
23 255         643 my $count = 0;
24 255         634 my $data = "";
25 255         2565 while ($status = filter_read()) {
26 152333 50       246705 return $status if $status < 0;
27            
28 152333 50 33     509032 if (defined($terminator) && m/$terminator/) {
29 0         0 $off=1;
30 0         0 last;
31             }
32 152333 100       265154 if (m/^\s*(__END__|__DATA__)\s*$/) {
33 1         5 $end=$1; $off = 1;
  1         2  
34 1         3 last;
35             }
36 152332         218416 $data .= $_;
37 152332         177070 $count++;
38 152332         339055 $_ = "";
39             }
40 255         7244 $_ = $data;
41 255 50       2377 $_ = findslice $_ unless $status < 0; # the actual filter
42 255 100       1279 $_ .= "no $class;\n" if $off;
43 255 100       858 $_ .= "$end\n" if $end;
44 255         31929 return $count;
45             }
46 128         1025 );
47             }
48              
49             sub unimport {
50 1     1   2068 filter_del();
51             }
52              
53             1;