From 6e012ee749903e4b5b49004e12b30a69be5bf911 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 21 Jun 2013 10:04:21 -0400 Subject: make runtime warnings optional --- lib/Dist/CheckConflicts.pm | 85 ++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 41 deletions(-) (limited to 'lib') diff --git a/lib/Dist/CheckConflicts.pm b/lib/Dist/CheckConflicts.pm index a3746d3..1fea9e2 100644 --- a/lib/Dist/CheckConflicts.pm +++ b/lib/Dist/CheckConflicts.pm @@ -120,52 +120,55 @@ sub import { $CONFLICTS{$for} = \%conflicts; $DISTS{$for} = $dist || $for; - for my $conflict (keys %conflicts) { - $HAS_CONFLICTS{$conflict} ||= []; - push @{ $HAS_CONFLICTS{$conflict} }, $for; - } - # warn for already loaded things... - for my $conflict (keys %conflicts) { - (my $file = $conflict) =~ s{::}{/}g; - $file .= '.pm'; - if (exists $INC{$file}) { - _check_version([$for], $conflict); + if (grep { $_ eq ':runtime' } @_) { + for my $conflict (keys %conflicts) { + $HAS_CONFLICTS{$conflict} ||= []; + push @{ $HAS_CONFLICTS{$conflict} }, $for; } - } - - # and warn for subsequently loaded things... - @INC = grep { - !(ref($_) eq 'ARRAY' && @$_ > 1 && $_->[1] == \%CONFLICTS) - } @INC; - unshift @INC, [ - sub { - my ($sub, $file) = @_; - - (my $mod = $file) =~ s{\.pm$}{}; - $mod =~ s{/}{::}g; - return unless $mod =~ /[\w:]+/; - return unless defined $HAS_CONFLICTS{$mod}; - - { - local $HAS_CONFLICTS{$mod}; - require $file; + # warn for already loaded things... + for my $conflict (keys %conflicts) { + (my $file = $conflict) =~ s{::}{/}g; + $file .= '.pm'; + if (exists $INC{$file}) { + _check_version([$for], $conflict); } + } - _check_version($HAS_CONFLICTS{$mod}, $mod); - - # the previous require already handled it - my $called; - return sub { - return 0 if $called; - $_ = "1;"; - $called = 1; - return 1; - }; - }, - \%CONFLICTS, # arbitrary but unique, see above - ]; + # and warn for subsequently loaded things... + @INC = grep { + !(ref($_) eq 'ARRAY' && @$_ > 1 && $_->[1] == \%CONFLICTS) + } @INC; + unshift @INC, [ + sub { + my ($sub, $file) = @_; + + (my $mod = $file) =~ s{\.pm$}{}; + $mod =~ s{/}{::}g; + return unless $mod =~ /[\w:]+/; + + return unless defined $HAS_CONFLICTS{$mod}; + + { + local $HAS_CONFLICTS{$mod}; + require $file; + } + + _check_version($HAS_CONFLICTS{$mod}, $mod); + + # the previous require already handled it + my $called; + return sub { + return 0 if $called; + $_ = "1;"; + $called = 1; + return 1; + }; + }, + \%CONFLICTS, # arbitrary but unique, see above + ]; + } $pkg->export_to_level(1, @_); } -- cgit v1.2.3-54-g00ecf