NAME
builtins::compat - install all the new builtins from the builtin namespace (Perl 5.36+), and try our best on older versions of Perl
SYNOPSIS
use 5.008001; # Or later
use builtins::compat; # Loads all new builtins
# So now we can write...
if ( reftype($x) eq 'ARRAY' || blessed($x) ) {
print refaddr($x), "\n";
if ( is_weak($x) ) {
unweaken($x);
print ceil( refaddr($x) / floor($y) ), "\n";
weaken($x);
print trim($description), "\n";
}
}
DESCRIPTION
This module does the same as builtins on Perl 5.36 and above. On older versions of Perl, it tries to implement the same functions and then clean them from your namespace using namespace::clean.
The pre-5.36 versions of created_as_number
, created_as_string
, and is_bool
may not be 100% perfect implementations.
IMPORT
To import the functions provided in Perl 5.36:
use builtins::compat qw( :5.36 );
If future versions of Perl add more functions to builtin, then these will be provided under different version number tags.
Importing use builtins::compat
with no arguments will import the Perl 5.36 builtins, even if you're using a newer version of Perl.
You can import only specific functions by listing their names:
use builtins::compat qw( refaddr reftype );
You can exclude specific functions by name too. For all the Perl 5.36 functions except indexed
:
use builtins::compat qw( :5.36 !indexed );
BUGS
Please report any bugs to https://github.com/tobyink/p5-builtins-compat/issues.
SEE ALSO
builtins, builtin, Scalar::Util.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2022 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.