How do I redefine a builtin function, operator, or method?

Why do you want to do that? :-)

If you want to override a predefined function, such as open(), then you'll have to import the new definition from a different module. See perlsub/"Overriding Built-in Functions". There's also an example in perltoot/"Class::Template".

If you want to overload a Perl operator, such as + or **, then you'll want to use the use overload pragma, documented in overload.

If you're talking about obscuring method calls in parent classes, see perltoot/"Overridden Methods".


Back to perlfaq7