|
File::Basename::Object - Object-oriented syntax sugar for File::Basename |
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. 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:
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 the File::Basename manpage for more information.
fullname($newname)$newname is specified, that is
taken as the new pathname. The old pathname is returned.
suffixlist(@suffixes)@suffixes is specified, that is taken as the new list
of suffixes. The old list of suffixes is returned.
copy($newname)$newname is specified, that is used as
the fullname for the new object.
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 - Object-oriented syntax sugar for File::Basename |