Front page | perl.perl5.changes |
Postings from February 2009
[perl.git] branch blead, updated. GitLive-blead-687-ge76b2c0
From:
Nicholas Clark
Date:
February 23, 2009 02:31
Subject:
[perl.git] branch blead, updated. GitLive-blead-687-ge76b2c0
Message ID:
E1LbY5y-0005CB-CR@camel.booking.com
In perl.git, the branch blead has been updated
<http://perl5.git.perl.org/perl.git/commitdiff/e76b2c0c0a5a6bcf7f940f55f050b6f3cecac437?hp=f785e3a13bdb70150178a2baa433614531998f17>
- Log -----------------------------------------------------------------
commit e76b2c0c0a5a6bcf7f940f55f050b6f3cecac437
Author: Nicholas Clark <nick@ccl4.org>
Date: Mon Feb 23 11:27:08 2009 +0100
Add deprecate.pm. Deprecate shipping Switch.pm in the core distribution.
-----------------------------------------------------------------------
Summary of changes:
MANIFEST | 1 +
lib/Switch.pm | 4 +++-
lib/deprecate.pm | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletions(-)
create mode 100644 lib/deprecate.pm
diff --git a/MANIFEST b/MANIFEST
index cfa871e..ca5213f 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1940,6 +1940,7 @@ lib/DBM_Filter/utf8.pm DBM Filter for UTF-8 Encoding
lib/dbm_filter_util.pl Utility functions used by DBM Filter tests
lib/DB.pm Debugger API (draft)
lib/DB.t See if DB works
+lib/deprecate.pm A pragma for deprecating modules from the core.
lib/Devel/SelfStubber.pm Generate stubs for SelfLoader.pm
lib/Devel/SelfStubber.t See if Devel::SelfStubber works
lib/diagnostics.pm Print verbose diagnostics
diff --git a/lib/Switch.pm b/lib/Switch.pm
index 709442e..8e98d29 100644
--- a/lib/Switch.pm
+++ b/lib/Switch.pm
@@ -4,8 +4,10 @@ use strict;
use vars qw($VERSION);
use Carp;
-$VERSION = '2.14';
+use if $] >= 5.011, 'deprecate';
+$VERSION = '2.14_01';
+
# LOAD FILTERING MODULE...
use Filter::Util::Call;
diff --git a/lib/deprecate.pm b/lib/deprecate.pm
new file mode 100644
index 0000000..23c045b
--- /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;
--
Perl5 Master Repository
-
[perl.git] branch blead, updated. GitLive-blead-687-ge76b2c0
by Nicholas Clark