diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-02-23 11:27:08 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-02-23 11:27:08 +0100 |
commit | e76b2c0c0a5a6bcf7f940f55f050b6f3cecac437 (patch) | |
tree | 2dbc90af9526d15e362f33a09b3ecf096a795246 /lib/deprecate.pm | |
parent | f785e3a13bdb70150178a2baa433614531998f17 (diff) | |
download | perl-e76b2c0c0a5a6bcf7f940f55f050b6f3cecac437.tar.gz |
Add deprecate.pm. Deprecate shipping Switch.pm in the core distribution.
Diffstat (limited to 'lib/deprecate.pm')
-rw-r--r-- | lib/deprecate.pm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/deprecate.pm b/lib/deprecate.pm new file mode 100644 index 0000000000..23c045b4e9 --- /dev/null +++ b/lib/deprecate.pm @@ -0,0 +1,40 @@ +#!perl -w +use strict; + +package deprecate; +use Config; +use Carp; +use warnings; +our $VERSION = 0.01; + +sub import { + my ($package, $file, $line) = caller; + my $expect_leaf = "$package.pm"; + $expect_leaf =~ s!::!/!g; + + foreach my $pair ([qw(sitearchexp archlibexp)], + [qw(sitelibexp privlibexp)]) { + my ($site, $priv) = @Config{@$pair}; + # Just in case anyone managed to configure with trailing /s + s!/*$!!g foreach $site, $priv; + + next if $site eq $priv; + if ("$priv/$expect_leaf" eq $file) { + # This is fragile, because it + # 1: depends on the number of call stacks in if.pm + # 2: is directly poking in the internals of warnings.pm + my ($call_file, $call_line, $callers_bitmask) = (caller 3)[1,2,9]; + + if (defined $callers_bitmask + && (vec($callers_bitmask, $warnings::Offsets{deprecated}, 1) + || vec($callers_bitmask, $warnings::Offsets{all}, 1))) { + warn <<"EOM"; +$package will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at $call_file line $call_line +EOM + } + return; + } + } +} + +1; |