| File-Basename-Object documentation | view source | Contained in the File-Basename-Object distribution. |
File::Basename::Object - Object-oriented syntax sugar for File::Basename
my $file = File::Basename::Object->new("/path/to/a/file.html", ".htm", ".html");
if(open(my $fh, '<', $file)) {
print "Now reading ", $file->basename, "\n";
...
}
if($file == "/another/path/to/file.htm") {
print "$file shares it's base name with /another/path/to/file.htm\n";
}
File::Basename::Object is an object-oriented wrapper around
File::Basename (File::Basename). The goal is to allow pathnames to be
presented and manipulated easily.
A File::Basename::Object stringifies to it's full canonical pathname,
so it can be used in open(), etc. without any trouble. When compared as
a string (cmp, ne, eq, etc), it's full canonical pathname is
compared. When compared using numeric operators (==, !=, etc), the
file's base name is compared instead. Some methods are also provided:
Creates a new File::Basename::Object. $fullname is the full pathname
you wish to store, and @suffixlist is an option list of suffixes that you
are interested in removing from the file's name to obtain it's base.
Suffixes can be strings or regular expressions (qr{...});
see File::Basename for more information.
These three methods execute their counterparts in File::Basename (File::Basename) with the same arguments as were given in the object's constructor.
Get and/or set the full pathname. If $newname is specified, that is
taken as the new pathname. The old pathname is returned.
Get and/or set the list of suffixes we wish to strip from the file's
base name. If @suffixes is specified, that is taken as the new list
of suffixes. The old list of suffixes is returned.
Clear the list of suffixes, so that no suffixes are stripped from the file's base name. The old list of suffixes is returned.
Return a clone of this object. If $newname is specified, that is used as
the fullname for the new object.
File::Basename
Tyler "Crackerjack" MacDonald <japh@crackerjack.net>
Copyright 2006 Tyler MacDonald.
This is free software; you may redistribute it under the same terms as perl itself.
| File-Basename-Object documentation | view source | Contained in the File-Basename-Object distribution. |