| 1 | # | ||||||||||||||
| 2 | # $Id: Poem.pm,v 0.1 2006/03/25 10:43:27 dankogai Exp dankogai $ | ||||||||||||||
| 3 | # | ||||||||||||||
| 4 | package Poem; | ||||||||||||||
| 5 | 1 | ▶ | use 5.008001; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 1 | our $VERSION = sprintf "%d.%02d", q$Revision: 0.1 $ =~ /(\d+)/g; | |||||||||||||
| 9 | |||||||||||||||
| 10 | 1 | ▶ | use Filter::Util::Call; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 1 | my %opt = (); | |||||||||||||
| 12 | 1 | ▶ | sub import{ | ||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.2
| |||||||||||||||
| 13 | 1 | my $class = shift; | |||||||||||||
| 14 | 0 | %opt = map { $_ => 1 } @_; | |||||||||||||
| 15 | 1 | filter_add(\&read_poem); | |||||||||||||
| 16 | } | ||||||||||||||
| 17 | 0 | ▶ | sub unimport{ | ||||||||||||
|
Subroutine
unimport: not called CC=1 SCAR=6.9
| |||||||||||||||
| 18 | 0 | my $class = shift; | |||||||||||||
| 19 | 0 | filter_del(); | |||||||||||||
| 20 | 0 | %opt = (); | |||||||||||||
| 21 | } | ||||||||||||||
| 22 | 1 | ▶ | sub read_poem{ | ||||||||||||
|
Subroutine
read_poem: called CC=11 SCAR=37.1
Pod
undocumented
| |||||||||||||||
| 23 | 1 | my $pkg = __PACKAGE__; | |||||||||||||
| 24 | 1 | my ($status, $no_seen, @poem); | |||||||||||||
| 25 | 1 | ▶ | while ($status = filter_read()) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 26 | 6 | ▶ | if (/^\s*no\s+$pkg\s*;\s*?$/) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 27 | 0 | $no_seen=1; | |||||||||||||
| 28 | 0 | last; | |||||||||||||
| 29 | } | ||||||||||||||
| 30 | 6 | push @poem, $_; | |||||||||||||
| 31 | 6 | $_ = q(); | |||||||||||||
| 32 | } | ||||||||||||||
| 33 | 1 | ▶ | if ($opt{-review}){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 34 | # eval does not work in filter. So we ask via pipe | ||||||||||||||
| 35 | 0 | print "# Your Poem:\n"; | |||||||||||||
| 36 | 0 | print @poem; | |||||||||||||
| 37 | my $perlopt = | ||||||||||||||
| 38 | $opt{-deparse} ? "-MO=Deparse" : | ||||||||||||||
| 39 | 0 | ▶ | $opt{-act} ? '-T' : '-Twc'; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 40 | 0 | print "# Review by $^X $perlopt\n"; | |||||||||||||
| 41 | 0 | ▶ | open my $perl, "| $^X $perlopt 2>&1" or die "$!"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 42 | 0 | ▶ | $opt{-strict} and print $perl "use strict;\n"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | 0 | ▶ | $opt{-utf8} and print $perl "use utf8;\n"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 44 | 0 | print $perl @poem; | |||||||||||||
| 45 | 0 | close $perl; | |||||||||||||
| 46 | }else{ | ||||||||||||||
| 47 | 1 | ▶ | print @poem unless $opt{-quiet}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 48 | } | ||||||||||||||
| 49 | 1 | ▶ | if ($no_seen){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | 0 | $_ .= "no $pkg;\n"; | |||||||||||||
| 51 | 0 | return 1; | |||||||||||||
| 52 | }else{ | ||||||||||||||
| 53 | 1 | return 0; | |||||||||||||
| 54 | } | ||||||||||||||
| 55 | } | ||||||||||||||
| 56 | |||||||||||||||
| 57 | # Preloaded methods go here. | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 1 | 1; | |||||||||||||
| 60 | __END__ | ||||||||||||||