http://qs321.pair.com?node_id=217423


in reply to Prototypes allow overloading subs?

If you want clean function overloading in Perl take a look at Class::Multimethods.

There's also the appropriately named overload module, which I have yet to use but looks interesting.

Update: Here's an example with Class::Multimethods:

use Class::Multimethods; multimethod add => ('#', '#') => sub { $ans = $_[0] + $_[1]; print $ans, "\n" }; multimethod add => ('$', '$') => sub { $ans = $_[0] . $_[1]; print $ans, "\n" }; add(1, 2); add("Foo", "Bar");

Is this what you're thinking of?