Short answer: No, this is really impossible.
The long answer: after loading File :: Path, you cannot prevent the code from calling File::Path::make_path() , but you can limit the area in which it is available to a short name.
use File::Path (); sub load { local *make_path = \&File::Path::make_path; make_path('foo/bar/baz');
But, using local , the scope is not lexically limited by the syntax code block. This is a dynamically limited value, meaning that all code called load() will also see make_path as a working routine.
I would recommend not using this technique because it is unclear and it can be difficult to explain the side effects from a distance. Basically, I find this useful for writing unit tests where you could replace some features with layouts.
Perl developers are discussing the addition of lexical subnets as part of the language. This function should allow you to do almost what you want, with no problems using local . But this is still ongoing and not even available in perl development releases.
source share