| 1 | package PM::Packages; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use 5.00405; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 5 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 5 | our @EXPORT_OK = qw( pm_packages ); | |||||||||||||||||||||||||||
| 9 | 5 | our @EXPORT = @EXPORT_OK; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Exporter qw( import ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub pm_packages | ||||||||||||||||||||||||||||
| 14 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
pm_packages: called CC=16 SCAR=28.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 5 | my( $pmfile ) = @_; | |||||||||||||||||||||||||||
| 16 | 5 | my @ret; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 5 | ▶ | open my $fh, "<", "$pmfile" or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 5 | local $/ = "\n"; | |||||||||||||||||||||||||||
| 21 | 5 | my $inpod = 0; | |||||||||||||||||||||||||||
| 22 | 5 | ▶ | PLINE: while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 86 | chomp; | |||||||||||||||||||||||||||
| 24 | 86 | my($pline) = $_; | |||||||||||||||||||||||||||
| 25 | 86 | ▶ | $inpod = $pline =~ /^=(?!cut)/ ? 1 : | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 26 | $pline =~ /^=cut/ ? 0 : $inpod; | ||||||||||||||||||||||||||||
| 27 | 86 | ▶ | next if $inpod; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 82 | ▶ | next if substr($pline,0,4) eq "=cut"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 81 | $pline =~ s/\#.*//; | |||||||||||||||||||||||||||
| 31 | 81 | ▶ | next if $pline =~ /^\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 39 | ▶ | if ($pline =~ /^__(?:END|DATA)__\b/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pline =~ /^__(?:END|DATA)__\b/ and not $pmfile =~ /\.PL$/
MC/DC50%1/2
$pline =~ /^__(?:END|DATA)__\b/ and not $pmfile =~ /\.PL$/
$pline =~ /^__(?:END|DATA)__\b/
not $pmfile =~ /\.PL$/
Truth table66%2/3
A and not(B)
A= $pline =~ /^__(?:END|DATA)__\b/B= not $pmfile =~ /\.PL$/
| |||||||||||||||||||||||||||||
| 33 | and $pmfile !~ /\.PL$/ # PL files may well have code after __DATA__ | ||||||||||||||||||||||||||||
| 34 | ){ | ||||||||||||||||||||||||||||
| 35 | 2 | last PLINE; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 37 | my $pkg; | |||||||||||||||||||||||||||
| 39 | my $strict_version; | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 37 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | $pline =~ m{ | ||||||||||||||||||||||||||||
| 43 | (.*) | ||||||||||||||||||||||||||||
| 44 | (?<![*\$\\@%&]) # no sigils | ||||||||||||||||||||||||||||
| 45 | \bpackage\s+ | ||||||||||||||||||||||||||||
| 46 | ([\w\:\']+) | ||||||||||||||||||||||||||||
| 47 | \s* | ||||||||||||||||||||||||||||
| 48 | (?: $ | [\}\;] | \{ | \s+($version::STRICT) ) | ||||||||||||||||||||||||||||
| 49 | }x) { | ||||||||||||||||||||||||||||
| 50 | 6 | $pkg = $2; | |||||||||||||||||||||||||||
| 51 | 6 | $strict_version = $3; | |||||||||||||||||||||||||||
| 52 | 6 | ▶ | if ($pkg eq "DB"){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | # XXX if pumpkin and perl make him comaintainer! I | ||||||||||||||||||||||||||||
| 54 | # think I always made the pumpkins comaint on DB | ||||||||||||||||||||||||||||
| 55 | # without further ado (?) | ||||||||||||||||||||||||||||
| 56 | 0 | next PLINE; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 37 | ▶ | if ($pkg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | # Found something | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | # from package | ||||||||||||||||||||||||||||
| 64 | 6 | $pkg =~ s/\'/::/; | |||||||||||||||||||||||||||
| 65 | # next PLINE unless $pkg =~ /^[A-Za-z]/; | ||||||||||||||||||||||||||||
| 66 | 6 | ▶ | next PLINE unless $pkg =~ /\w$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 6 | ▶ | next PLINE if $pkg eq "main"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | # Perl::Critic::Policy::TestingAndDebugging::ProhibitShebangWarningsArg | ||||||||||||||||||||||||||||
| 69 | # database for modid in mods, package in packages, package in perms | ||||||||||||||||||||||||||||
| 70 | # alter table mods modify modid varchar(128) binary NOT NULL default ''; | ||||||||||||||||||||||||||||
| 71 | # alter table packages modify package varchar(128) binary NOT NULL default ''; | ||||||||||||||||||||||||||||
| 72 | 6 | ▶ | next PLINE if length($pkg) > 128; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 6 | push @ret, $pkg; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 5 | $fh->close; | |||||||||||||||||||||||||||
| 78 | 5 | return @ret; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 5 | 1; | |||||||||||||||||||||||||||
| 83 | __END__ | ||||||||||||||||||||||||||||