table of contents
- Tumbleweed 0.01-64.33
- Leap-15.6
File::Basename::Object(3) | User Contributed Perl Documentation | File::Basename::Object(3) |
NAME¶
File::Basename::Object - Object-oriented syntax sugar for File::Basename
SYNOPSIS¶
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"; }
DESCRIPTION¶
"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:
CONSTRUCTOR¶
- File::Basename::Object->new($fullname, @suffixlist)
- 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.
METHODS¶
- $object->fileparse
- $object->basename
- $object->dirname
- These three methods execute their counterparts in File::Basename with the same arguments as were given in the object's constructor.
- $object->fullname($newname)
- Get and/or set the full pathname. If $newname is specified, that is taken as the new pathname. The old pathname is returned.
- $object->suffixlist(@suffixes)
- 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.
- $object->no_suffixes
- Clear the list of suffixes, so that no suffixes are stripped from the file's base name. The old list of suffixes is returned.
- $object->copy($newname)
- Return a clone of this object. If $newname is specified, that is used as the fullname for the new object.
SEE ALSO¶
File::Basename
AUTHOR¶
Tyler "Crackerjack" MacDonald <japh@crackerjack.net>
LICENSE¶
Copyright 2006 Tyler MacDonald.
This is free software; you may redistribute it under the same terms as perl itself.
2011-11-18 | perl v5.40.0 |