Perl 5 version 26.3 documentation

overloading

NAME

overloading - perl pragma to lexically control overloading

SYNOPSIS

  1. {
  2. no overloading;
  3. my $str = "$object"; # doesn't call stringification overload
  4. }
  5. # it's lexical, so this stringifies:
  6. warn "$object";
  7. # it can be enabled per op
  8. no overloading qw("");
  9. warn "$object";
  10. # and also reenabled
  11. use overloading;

DESCRIPTION

This pragma allows you to lexically disable or enable overloading.

  • no overloading

    Disables overloading entirely in the current lexical scope.

  • no overloading @ops

    Disables only specific overloads in the current lexical scope.

  • use overloading

    Reenables overloading in the current lexical scope.

  • use overloading @ops

    Reenables overloading only for specific ops in the current lexical scope.