summaryrefslogtreecommitdiff
path: root/lib/UNIVERSAL.pm
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2014-06-08 01:37:32 +0100
committerTony Cook <tony@develop-help.com>2014-07-21 11:55:18 +1000
commit1178d2cf03fa59bca77887516dd7d996bb17357c (patch)
treeacd04470a73c7b6ca353b0841a1e4565910a2abf /lib/UNIVERSAL.pm
parente81c4bddb20ee382f91769de9a783a3a2a3b0489 (diff)
downloadperl-1178d2cf03fa59bca77887516dd7d996bb17357c.tar.gz
Disallow importing functions from UNIVERSAL
It's been deprecated since v5.12.
Diffstat (limited to 'lib/UNIVERSAL.pm')
-rw-r--r--lib/UNIVERSAL.pm29
1 files changed, 8 insertions, 21 deletions
diff --git a/lib/UNIVERSAL.pm b/lib/UNIVERSAL.pm
index 1adf09c272..2f16cb544a 100644
--- a/lib/UNIVERSAL.pm
+++ b/lib/UNIVERSAL.pm
@@ -1,27 +1,18 @@
package UNIVERSAL;
-our $VERSION = '1.11';
+our $VERSION = '1.12';
# UNIVERSAL should not contain any extra subs/methods beyond those
-# that it exists to define. The use of Exporter below is a historical
-# accident that can't be fixed without breaking code. Note that we
-# *don't* set @ISA here, as we don't want all classes/objects inheriting from
-# Exporter. It's bad enough that all classes have a import() method
-# whenever UNIVERSAL.pm is loaded.
-require Exporter;
-@EXPORT_OK = qw(isa can VERSION);
+# that it exists to define. The existence of import() below is a historical
+# accident that can't be fixed without breaking code.
# Make sure that even though the import method is called, it doesn't do
# anything unless called on UNIVERSAL.
sub import {
return unless $_[0] eq __PACKAGE__;
return unless @_ > 1;
- require warnings;
- warnings::warnif(
- 'deprecated',
- 'UNIVERSAL->import is deprecated and will be removed in a future perl',
- );
- goto &Exporter::import;
+ require Carp;
+ Carp::croak("UNIVERSAL does not export anything");
}
1;
@@ -190,13 +181,9 @@ available to your program (and you should not do so).
=head1 EXPORTS
-None by default.
+None.
-You may request the import of three functions (C<isa>, C<can>, and C<VERSION>),
-B<but this feature is deprecated and will be removed>. Please don't do this in
-new code.
-
-For example, previous versions of this documentation suggested using C<isa> as
+Previous versions of this documentation suggested using C<isa> as
a function to determine the type of a reference:
use UNIVERSAL 'isa';
@@ -204,7 +191,7 @@ a function to determine the type of a reference:
$yes = isa $h, "HASH";
$yes = isa "Foo", "Bar";
-The problem is that this code will I<never> call an overridden C<isa> method in
+The problem is that this code would I<never> call an overridden C<isa> method in
any class. Instead, use C<reftype> from L<Scalar::Util> for the first case:
use Scalar::Util 'reftype';