in reply to Namespaces & colliding names
G'day jahero,
Welcome to the Monastery.
++Athanasius showed in his response how to stop all imports with:
use File::Basename ();
However, there may be cases where you only want to stop some, but not all, imports. Still using File::Basename as an example, let's say you wanted its dirname() function. You can specify importation of that function like this:
use File::Basename qw{dirname};
Module documentation will often identify which functions are exported by default and which are optionally exported; however, presence of this information is by no means guaranteed. You can check for yourself by looking at the source code: @EXPORT lists the default exports and @EXPORT_OK lists the optional ones. For example, the File::Basename source code shows four default exports:
@EXPORT = qw(fileparse fileparse_set_fstype basename dirname);
See Exporter for a lot more information on this including advanced features. For instance, to exclude basename() only, you could write:
use File::Basename qw{!basename};
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Namespaces & colliding names
by jahero (Pilgrim) on Nov 08, 2016 at 09:34 UTC |