File::Basename
Native Rust implementation built into the interpreter. Runtime: PP. See original documentation for the full Perl reference.
Provides path parsing functions: basename, dirname, fileparse.
Synopsis
use File::Basename qw(basename dirname fileparse);
my $base = basename("/usr/local/bin/perl"); # "perl"
my $dir = dirname("/usr/local/bin/perl"); # "/usr/local/bin"
my ($name, $path, $suffix) = fileparse(
"/usr/local/lib/libperl.so", qr/\.[^.]*/
);
# $name="libperl", $path="/usr/local/lib/", $suffix=".so"
Functions
basename
Returns the last component of a path, optionally removing a suffix. Trailing slashes are removed before extracting the last component.
dirname
Returns the directory portion of a path. Returns "." if the
path contains no directory component.
fileparse
Splits a path into (name, directory, suffix). This is the
underlying function for basename and dirname. Suffixes can
be strings or regex patterns.
fileparse_set_fstype
Set the filesystem type for path parsing. Always returns “Unix”; the argument is accepted but ignored.
Synopsis
use File::Basename 'fileparse_set_fstype';
fileparse_set_fstype('Unix');