File Coverage

blib/lib/Acme/Filter/Kenny.pm
Criterion Covered Total %
statement 34 34 100.0
branch 8 8 100.0
condition 3 3 100.0
subroutine 8 8 100.0
pod 0 2 0.0
total 53 55 96.3


line stmt bran cond sub pod time code
1             ## Acme::Filter::Kenny - Kenny-speak source filter for Perl
2             ## Copyright (C) 2004 Gergely Nagy
3             ##
4             ## This file is part of Acme::Filter::Kenny.
5             ##
6             ## Acme::Filter::Kenny is free software; you can redistribute it
7             ## and/or modify it under the terms of the GNU General Public License
8             ## as published by the Free Software Foundation; version 2 dated June,
9             ## 1991.
10             ##
11             ## Acme::Filter::Kenny is distributed in the hope that it will be
12             ## useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13             ## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14             ## GNU General Public License for more details.
15             ##
16             ## You should have received a copy of the GNU General Public License
17             ## along with this program; if not, write to the Free Software
18             ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19             ## USA.
20              
21             package Acme::Filter::Kenny;
22              
23 2     2   1742 use strict;
  2         3  
  2         69  
24 2     2   11 use warnings;
  2         4  
  2         53  
25 2     2   2659 use Filter::Util::Call;
  2         2539  
  2         145  
26 2     2   12 use vars qw($VERSION $iq_kenny);
  2         4  
  2         1683  
27              
28             $VERSION = "1.01";
29             $iq_kenny = 0;
30              
31             sub KennyIt {
32 7     7 0 23 ($_)=@_;my($p,$f);$p=3-2*/[^\W\dmpf_]/i;s.[a-z]{$p}.vec($f=join('',$p-1?chr(
  7     34   10  
  7         24  
  7         132  
  34         123  
33 102         373 sub{$_[0]*9+$_[1]*3+$_[2] }->(map {/p|f/i+/f/i}split//,$&)+97):('m','p','f')
  60         147  
34 54 100       173 [map{((ord$&)%32-1)/$_%3}(9, 3,1)]),5,1)='`'lt$&;$f.eig;return ($_);
  54         220  
  7         20  
35             };
36              
37             sub import {
38 2     2   15 my ($type, @params) = @_;
39 2         5 my ($ref) = [];
40              
41 2 100       11 if (grep {/^:iq_kenny$/} @params) {
  1         265  
42 1         3 $iq_kenny = 1;
43             }
44 2         9 filter_add (bless $ref);
45             }
46              
47             sub filter {
48 14     14 0 63282 my $self = (@_);
49 14         19 my ($status);
50 14 100       83 if (($status = filter_read ()) > 0) {
51 12 100 100     77 if ($iq_kenny == 0 ||
52             m/^[^a-z]*[mfp]{3}(?:[^a-z]|[mfp]{3})+$/i) {
53 7         17 KennyIt ($_);
54             }
55             }
56 14         4608 $status;
57             }
58              
59             1;
60              
61             __END__