Devel::...loadInfo(3)

πŸ’– Devel::...loadInfo(3) πŸ’–

okay so bestie, welcome to the User Contributed Perl Documentation corner of the manual β€” this is Devel::...loadInfo(3), and it is genuinely one of my fave lil introspection modules, no cap. Let's get into it 🫢


✨ NAME ✨

Devel::OverloadInfo β€” literally just here to snoop on your overloaded operators πŸ‘€


🌸 VERSION 🌸

version 0.008


πŸ¦‹ DESCRIPTION πŸ¦‹

Devel::OverloadInfo hands you the tea β˜• about overloaded operators for a given class (or an object, either one works), and it does not skimp on the details:

  • where in the inheritance hierarchy the overloads are declared, and
  • where the code implementing them actually lives πŸ’…

it's giving detective energy and honestly? obsessed.


πŸŽ€ FUNCTIONS πŸŽ€

is_overloaded πŸ’«

if (is_overloaded($class_or_object)) { ... }

Returns a boolean telling you whether the class or object you passed in has any overloading declared at all. And yes, bestie, pay attention: a bare use overload; with no actual operators still counts as being overloaded. Sneaky? A little. True? Very.

It's equivalent to overload::Overloaded(), but β€” and this is the slay part β€” it doesn't trigger the various bugs that come along with that function in versions of perl before 5.16. So if you're on ancient perl, this is your girl πŸ™ˆ

overload_op_info πŸ”

my $info = overload_op_info($class_or_object, $op);

Returns a hash reference with the info about one specific overloaded operator of the named class or blessed object.

If that operator isn't overloaded? You get undef. that's it, that's the answer, no notes 😭

For the list of available operators, peep "Overloadable Operations" in overload.

The keys in the returned hash are, in order:

  • class β€” the name of the class where the operator overloading was declared. πŸ‘‘
  • code β€” a reference to the function implementing the overloaded operator.
  • code_name β€” the fully qualified name of the function implementing the overloaded operator.
  • method_name (optional) β€” the name of the method implementing the overloaded operator, but only if the overloading was specified as a named method, like use overload $op => 'method';. 🎯
  • code_class (optional) β€” the name of the class where the method specified by method_name was found.
  • value (optional) β€” for the special fallback key, this is the value it was given in class.

overload_info 🌈

my $info = overload_info($class_or_object);

Returns a hash reference with info about all the overloaded operators of the specified class name or blessed object. The keys are the overloaded operators, exactly as specified in %overload::ops (again, see "Overloadable Operations" in overload), and the values are the hashes that overload_op_info returns. it's the whole squad, assembled πŸ«‚


πŸ’€ CAVEATS πŸ’€

Here's the messy part, bestie. Whether the fallback key exists when it has its default value of undef varies between perl versions:

  • Before 5.18 β€” it's there.
  • In later versions β€” it's not. πŸ’”

so like, vibe check your perl version before you go depending on it, fr fr.


πŸ‘‘ AUTHOR πŸ‘‘

Dagfinn Ilmari MannsΓ₯ker <ilmari@ilmari.org>


This software is copyright (c) 2014 by Dagfinn Ilmari MannsΓ₯ker.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 🧚


and that's the whole page, bestie!! this lil icon of a doc ships as part of perl v5.42.0 and was dated 2025-08-12 β€” mwah, go overload something responsibly πŸ’…βœ¨πŸ’–

πŸ“¦ where this page comes from