we’ll get nothing but basename:
use File::Basename qw/ basename /;
And here, we’ll ask for no new functions at all:
use File::Basename qw/ /;
This is also frequently written as:
use File::Basename ();
Why would you want to do that? Well, this directive tells Perl to load File::Base
name, just as before, but not to import any function names. Importing lets us use the
short, simple function names like basename and dirname. But even if we don’t import
those names, we can still use the functions. When they’re not imported, though, we
have to call them by their full names:
use File::Basename qw/ /; # import no function names
my $betty = &dirname($wilma); # uses our own subroutine &dirname
#(not shown)
my $name = "/usr/local/bin/perl";
my $dirname = File::Basename::dirname $name; # dirname from the module
阅读(649) | 评论(0) | 转发(0) |