blib/lib/PerlIO/via/Bastardize.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 60 CC 3 SCAR 12.8
CC
3
Cov
0%
import
6.0
FILL
6.0
PUSHED
2.0
CRAP 3.6
1 package PerlIO::via::Bastardize;
2 use 5.006;
3 use strict;
4 use Text::Bastardize;
5  
6 our $VERSION = '0.01';
7 our $method;
8  
9 our $bastard = new Text::Bastardize;
10 sub import {
11 shift;
12 my $arg = ref($_[0]) ? $_[0] : {@_};
13 $method = $arg->{method} || die "Method?\n";
14 }
15  
16 sub PUSHED {
17 my ($class,$mode,$fh) = @_;
18 my $buf = '';
19 return bless \$buf,$class;
20 }
21  
22 sub FILL {
23 my ($obj,$fh) = @_;
24 my $line = <$fh>;
25 my $ret;
26 if( defined $line ){
27 $bastard->charge($line);
28 eval '$ret = join q//, $bastard'."->$method(\$buf);";
29 return $ret;
30 }
31 else{
32 return undef;
33 }
34 }
35  
36 sub WRITE {
37 my ($obj,$buf,$fh) = @_;
38 my $bt;
39 $bastard->charge($buf);
40 eval '$$obj .= $bt = join q//,'."\$bastard->$method(\$buf);";
41 return length($bt);
42 }
43  
44 sub FLUSH {
45 my ($obj,$fh) = @_;
46 print $fh $$obj or return -1;
47 $$obj = '';
48 return 0;
49 }
50  
51  
52 1;
53 __END__