Scroll to navigation

builtin::compat(3pm) User Contributed Perl Documentation builtin::compat(3pm)

NAME

builtin::compat - Provide builtin functions for older perl versions

SYNOPSIS

  use builtin::compat qw(
    true
    false
    is_bool
    inf
    nan
    weaken
    unweaken
    is_weak
    blessed
    refaddr
    reftype
    created_as_string
    created_as_number
    stringify
    ceil
    floor
    trim
    indexed
    load_module
  );

DESCRIPTION

Provides builtin functions for perl versions that do not include the builtin module.

No functions are exported by default.

This module does its best to behave similar to builtin, which creates its exported functions as lexicals. The functions will be created in the currently compiling scope, not the immediate caller of "builtin::compat->import". The functions will also be removed at the end of the compilation scope using namespace::clean.

The builtin functions will be used directly when they are available.

FUNCTIONS

See "true" in builtin.
See "false" in builtin.
See "is_bool" in builtin.

Prior to perl 5.36, it was not possible to track boolean values fully accurately. This function will not be perfectly accurate on earlier perl versions.

See "inf" in builtin.
See "nan" in builtin.
See "weaken" in builtin.
See "unweaken" in builtin.
See "is_weak" in builtin.
See "blessed" in builtin.
See "refaddr" in builtin.
See "reftype" in builtin.
See "created_as_string" in builtin.

Prior to perl 5.36, it was not possible to check if a scalar value was created as a number or as a string fully accurately. This function will not be entirely accurate before then, but should be as accurate as is possible on these perl versions. In particular, a string like "12345" that has been used as a number will cause "create_as_string" to return false and "created_as_number" to return true.

See "created_as_number" in builtin.

Has the same caveats as "created_as_string".

See "stringify" in builtin.
See "ceil" in builtin.
See "floor" in builtin.
See "trim" in builtin.
See "indexed" in builtin.
See "load_module" in builtin.

AUTHOR

haarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>

CONTRIBUTORS

None so far.

COPYRIGHT

Copyright (c) 2022 the builtin::compat "AUTHOR" and "CONTRIBUTORS" as listed above.

LICENSE

This library is free software and may be distributed under the same terms as perl itself. See <https://dev.perl.org/licenses/>.

2024-11-15 perl v5.40.0