| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 9 |  |  | 9 |  | 158969 | use strict; | 
|  | 9 |  |  |  |  | 17 |  | 
|  | 9 |  |  |  |  | 299 |  | 
| 2 | 9 |  |  | 9 |  | 36 | use warnings; | 
|  | 9 |  |  |  |  | 14 |  | 
|  | 9 |  |  |  |  | 397 |  | 
| 3 |  |  |  |  |  |  | package Warnings::Version; | 
| 4 |  |  |  |  |  |  | $Warnings::Version::VERSION = '0.002003'; | 
| 5 |  |  |  |  |  |  | # ABSTRACT: Load warnings from a specific version of perl | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 9 |  |  | 9 |  | 163 | use 5.006; | 
|  | 9 |  |  |  |  | 26 |  | 
|  | 9 |  |  |  |  | 269 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 9 |  |  | 9 |  | 4446 | use Import::Into; | 
|  | 9 |  |  |  |  | 20195 |  | 
|  | 9 |  |  |  |  | 4033 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | my %warnings; | 
| 12 |  |  |  |  |  |  | $warnings{ categories } = [ qw/ all io severe syntax utf8 experimental / ]; | 
| 13 |  |  |  |  |  |  | $warnings{ all        } = [ qw/ closure exiting glob io closed exec newline | 
| 14 |  |  |  |  |  |  | pipe unopened misc numeric once overflow pack portable recursion redefine | 
| 15 |  |  |  |  |  |  | regexp debugging inplace internal malloc signal substr syntax ambiguous | 
| 16 |  |  |  |  |  |  | bareword deprecated digit parenthesis precedence printf prototype qw | 
| 17 |  |  |  |  |  |  | reserved semicolon taint uninitialized unpack untie utf8 void / ]; | 
| 18 |  |  |  |  |  |  | $warnings{ '5.6'      } = [ @{ $warnings{all} }, qw/ chmod umask y2k / ]; | 
| 19 |  |  |  |  |  |  | $warnings{ '5.8'      } = [ @{ $warnings{all} }, qw/ layer threads y2k / ]; | 
| 20 |  |  |  |  |  |  | $warnings{ '5.10'     } = [ @{ $warnings{all} }, qw/ layer threads / ]; | 
| 21 |  |  |  |  |  |  | $warnings{ '5.12'     } = [ @{ $warnings{all} }, qw/ layer imprecision | 
| 22 |  |  |  |  |  |  | illegalproto threads / ]; | 
| 23 |  |  |  |  |  |  | $warnings{ '5.14'     } = [ @{ $warnings{all} }, qw/ layer imprecision | 
| 24 |  |  |  |  |  |  | illegalproto threads surrogate non_unicode nonchar / ]; | 
| 25 |  |  |  |  |  |  | $warnings{ '5.16'     } = [ @{ $warnings{all} }, qw/ layer imprecision | 
| 26 |  |  |  |  |  |  | illegalproto threads surrogate non_unicode nonchar / ]; | 
| 27 |  |  |  |  |  |  | $warnings{ '5.18'     } = [ @{ $warnings{all} }, qw/ experimental::lexical_subs | 
| 28 |  |  |  |  |  |  | imprecision layer illegalproto threads non_unicode nonchar surrogate / ]; | 
| 29 |  |  |  |  |  |  | $warnings{ '5.20'     } = [ @{ $warnings{all} }, qw/ experimental::autoderef | 
| 30 |  |  |  |  |  |  | experimental::lexical_subs experimental::lexical_topic | 
| 31 |  |  |  |  |  |  | experimental::postderef experimental::regex_sets experimental::signatures | 
| 32 |  |  |  |  |  |  | experimental::smartmatch imprecision layer syscalls illegalproto threads | 
| 33 |  |  |  |  |  |  | non_unicode nonchar surrogate / ]; | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | sub import { | 
| 37 | 8 |  |  | 8 |  | 51 | my $package = shift; | 
| 38 | 8 |  |  |  |  | 9 | my $version = shift; | 
| 39 | 8 | 50 |  |  |  | 30 | $version = 'all' if not defined $version; | 
| 40 | 8 |  |  |  |  | 20 | warnings->import::into(scalar caller, get_warnings($version, $])); | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub unimport { | 
| 44 | 0 |  |  | 0 |  | 0 | my $package = shift; | 
| 45 | 0 |  |  |  |  | 0 | my $version = shift; | 
| 46 | 0 |  |  |  |  | 0 | warnings->unimport::from(scalar caller, get_warnings($version, $])); | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | sub get_warnings { | 
| 50 | 82 |  |  | 82 | 0 | 53168 | my $version      = massage_version(shift); | 
| 51 | 82 |  |  |  |  | 116 | my $perl_version = massage_version(shift); | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 82 | 50 |  |  |  | 206 | die "Unknown version: $version\n"           unless defined | 
| 54 |  |  |  |  |  |  | $warnings{ $version }; | 
| 55 | 82 | 50 |  |  |  | 145 | die "Unknown perl version: $perl_version\n" unless defined | 
| 56 |  |  |  |  |  |  | $warnings{ $perl_version }; | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 82 |  |  |  |  | 80 | my $wanted       = $warnings{ $version      }; | 
| 59 | 82 |  |  |  |  | 70 | my $available    = $warnings{ $perl_version }; | 
| 60 |  |  |  |  |  |  |  | 
| 61 | 82 |  |  |  |  | 109 | return intersection( $wanted, $available ); | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | sub massage_version { | 
| 65 | 171 |  |  | 171 | 0 | 882 | local $_ = shift; | 
| 66 |  |  |  |  |  |  |  | 
| 67 | 171 |  |  |  |  | 194 | s/(5\.\d+)\..*/$1/; | 
| 68 | 171 |  |  |  |  | 174 | s/(5\.\d\d\d).*/$1/; | 
| 69 | 171 |  |  |  |  | 534 | s/(5\.)0*/$1/; | 
| 70 |  |  |  |  |  |  |  | 
| 71 | 171 |  |  |  |  | 243 | return $_; | 
| 72 |  |  |  |  |  |  | } | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | sub intersection { | 
| 75 | 82 |  |  | 82 | 0 | 88 | my ($a1, $a2) = @_; | 
| 76 | 82 |  |  |  |  | 59 | my %count; | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 82 |  |  |  |  | 64 | return grep { $count{$_}++ == 1 } @{ $a1 }, @{ $a2 }; | 
|  | 7881 |  |  |  |  | 10002 |  | 
|  | 82 |  |  |  |  | 101 |  | 
|  | 82 |  |  |  |  | 158 |  | 
| 79 |  |  |  |  |  |  | } | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | 1; | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | __END__ |