summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Scalar
diff options
context:
space:
mode:
authorSiep Kroonenberg <siepo@cybercomm.nl>2024-02-15 21:14:42 +0000
committerSiep Kroonenberg <siepo@cybercomm.nl>2024-02-15 21:14:42 +0000
commit2ef219d80efde1bb5ab11cbdd8bdd059556b1f89 (patch)
tree95a8cb845703f263101ea7a0842bb75d93109bef /Master/tlpkg/tlperl/lib/Scalar
parent40aaa4ec3407e1ab404f4d1b0547205ac561269a (diff)
Perl 5.38.2
git-svn-id: svn://tug.org/texlive/trunk@69898 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Scalar')
-rw-r--r--Master/tlpkg/tlperl/lib/Scalar/Util.pm78
1 files changed, 45 insertions, 33 deletions
diff --git a/Master/tlpkg/tlperl/lib/Scalar/Util.pm b/Master/tlpkg/tlperl/lib/Scalar/Util.pm
index a7345aad78a..760e641ebf2 100644
--- a/Master/tlpkg/tlperl/lib/Scalar/Util.pm
+++ b/Master/tlpkg/tlperl/lib/Scalar/Util.pm
@@ -17,33 +17,17 @@ our @EXPORT_OK = qw(
dualvar isdual isvstring looks_like_number openhandle readonly set_prototype
tainted
);
-our $VERSION = "1.55";
+our $VERSION = "1.63";
$VERSION =~ tr/_//d;
require List::Util; # List::Util loads the XS
List::Util->VERSION( $VERSION ); # Ensure we got the right XS version (RT#100863)
-our @EXPORT_FAIL;
-
-unless (defined &weaken) {
- push @EXPORT_FAIL, qw(weaken);
-}
-unless (defined &isweak) {
- push @EXPORT_FAIL, qw(isweak isvstring);
-}
-unless (defined &isvstring) {
- push @EXPORT_FAIL, qw(isvstring);
-}
-
+# populating @EXPORT_FAIL is done in the XS code
sub export_fail {
- if (grep { /^(?:weaken|isweak)$/ } @_ ) {
- require Carp;
- Carp::croak("Weak references are not implemented in the version of perl");
- }
-
if (grep { /^isvstring$/ } @_ ) {
require Carp;
- Carp::croak("Vstrings are not implemented in the version of perl");
+ Carp::croak("Vstrings are not implemented in this version of perl");
}
@_;
@@ -80,6 +64,21 @@ being individual extensions would be wasteful.
By default C<Scalar::Util> does not export any subroutines.
+=head2 Core Perl C<builtin> Functions
+
+Many functions in this module have served as the inspiration for a new
+experimental facility in recent versions of Perl. From various development
+versions, starting at 5.35.7, equivalent functions to many of these utilities
+are available in the C<builtin::> package.
+
+ use Scalar::Util qw(blessed);
+
+ $class = blessed $obj;
+
+ $class = builtin::blessed $obj; # equivalent
+
+For more information, see the documentation on L<builtin>.
+
=cut
=head1 FUNCTIONS FOR REFERENCES
@@ -105,6 +104,9 @@ into is returned. Otherwise C<undef> is returned.
Take care when using this function simply as a truth test (such as in
C<if(blessed $ref)...>) because the package name C<"0"> is defined yet false.
+I<Since Perl version 5.35.7> an equivalent function is available as
+C<builtin::blessed>.
+
=head2 refaddr
my $addr = refaddr( $ref );
@@ -119,6 +121,9 @@ returned as a plain integer. Otherwise C<undef> is returned.
$obj = bless {}, "Foo";
$addr = refaddr $obj; # eg 88123488
+I<Since Perl version 5.35.7> an equivalent function is available as
+C<builtin::refaddr>.
+
=head2 reftype
my $type = reftype( $ref );
@@ -139,6 +144,9 @@ blessed references; thus C<ref()> returns the package name string C<"Regexp">
on these but C<reftype()> will return the underlying C structure type of
C<"REGEXP"> in all capitals.
+I<Since Perl version 5.35.7> an equivalent function is available as
+C<builtin::reftype>.
+
=head2 weaken
weaken( $ref );
@@ -178,6 +186,9 @@ references to objects will be strong, causing the remaining objects to never be
destroyed because there is now always a strong reference to them in the @object
array.
+I<Since Perl version 5.35.7> an equivalent function is available as
+C<builtin::weaken>.
+
=head2 unweaken
unweaken( $ref );
@@ -199,6 +210,9 @@ otherwise-equivalent code
(because in particular, simply assigning a weak reference back to itself does
not work to unweaken it; C<$REF = $REF> does not work).
+I<Since Perl version 5.35.7> an equivalent function is available as
+C<builtin::unweaken>.
+
=head2 isweak
my $weak = isweak( $ref );
@@ -215,6 +229,9 @@ B<NOTE>: Copying a weak reference creates a normal, strong, reference.
$copy = $ref;
$weak = isweak($copy); # false
+I<Since Perl version 5.35.7> an equivalent function is available as
+C<builtin::is_weak>.
+
=head1 OTHER FUNCTIONS
=head2 dualvar
@@ -241,24 +258,24 @@ true.
$dual = isdual($foo); # true
Note that a scalar can be made to have both string and numeric content through
-numeric operations:
+standard operations:
$foo = "10";
$dual = isdual($foo); # false
$bar = $foo + 0;
$dual = isdual($foo); # true
-Note that although C<$!> appears to be a dual-valued variable, it is
-actually implemented as a magical variable inside the interpreter:
+The C<$!> variable is commonly dual-valued, though it is also magical in other
+ways:
$! = 1;
+ $dual = isdual($!); # true
print("$!\n"); # "Operation not permitted"
- $dual = isdual($!); # false
-
-You can capture its numeric and string content using:
- $err = dualvar $!, $!;
- $dual = isdual($err); # true
+B<CAUTION>: This function is not as useful as it may seem. Dualvars are not a
+distinct concept in Perl, but a standard internal construct of all scalar
+values. Almost any value could be considered as a dualvar by this function
+through the course of normal operations.
=head2 isvstring
@@ -324,12 +341,7 @@ Module use may give one of the following errors during import.
=over
-=item Weak references are not implemented in the version of perl
-
-The version of perl that you are using does not implement weak references, to
-use L</isweak> or L</weaken> you will need to use a newer release of perl.
-
-=item Vstrings are not implemented in the version of perl
+=item Vstrings are not implemented in this version of perl
The version of perl that you are using does not implement Vstrings, to use
L</isvstring> you will need to use a newer release of perl.