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 123     123   70737 use Filter::Util::Call;
  123         117975  
  123         46011  
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 130     130   2217 my ($class) = @_;
14 130         631 ($file,$offset) = (caller)[1,2]; # for error reporting
15 130         528 $offset++;
16            
17             ## Parse class name into a regexp suitable for filtration
18 130         501 my $terminator = terminator_regexp($class);
19              
20             filter_add(
21             sub {
22 259     259   79154 my ($status, $off, $end);
23 259         698 my $count = 0;
24 259         624 my $data = "";
25 259         2550 while ($status = filter_read()) {
26 153809 50       246585 return $status if $status < 0;
27            
28 153809 50 33     515537 if (defined($terminator) && m/$terminator/) {
29 0         0 $off=1;
30 0         0 last;
31             }
32 153809 100       268994 if (m/^\s*(__END__|__DATA__)\s*$/) {
33 1         7 $end=$1; $off = 1;
  1         2  
34 1         3 last;
35             }
36 153808         221864 $data .= $_;
37 153808         179398 $count++;
38 153808         344621 $_ = "";
39             }
40 259         7565 $_ = $data;
41 259 50       2512 $_ = findslice $_ unless $status < 0; # the actual filter
42 259 100       1304 $_ .= "no $class;\n" if $off;
43 259 100       832 $_ .= "$end\n" if $end;
44 259         34062 return $count;
45             }
46 130         1117 );
47             }
48              
49             sub unimport {
50 1     1   1784 filter_del();
51             }
52              
53             1;