Example for override function in Perl

overriding, perl

Solution

http://perldoc.perl.org/perlsub.html#Overriding-Built-in-Functions

Many built-in functions may be overridden, though this should be tried only occasionally and for good reason. Typically this might be done by a package attempting to emulate missing built-in functionality on a non-Unix system.

Overriding may be done only by importing the name from a module at compile time--ordinary predeclaration isn't good enough. However, the use subs pragma lets you, in effect, predeclare subs via the import syntax, and these names may then override built-in ones:

Example:

use subs 'chdir', 'chroot', 'chmod', 'chown';
chdir $somewhere;
sub chdir { ... }

Note: all of the above was extracted from the above link

Problem

Could you please elaborate on override function in Perl. Some simple examples will be great to understand.

Original source