++ed by:

5 PAUSE users

Alexandra Hrefna Maheu


Filesys::POSIX::Path - Pathname manipulation utility class


    use Filesys::POSIX::Path;

    my $path = Filesys::POSIX::Path->new('/foo/bar/baz');

    printf("%s\n", $path->basename); # outputs 'baz'
    printf("%s\n", $path->dirname);  # outputs '/foo/bar'

    # outputs '/foo/bar/../baz'
    printf("%s\n", $path->full('/foo/./././bar/../baz'));


This module provides an object-oriented approach to path cleanup and introspection.



Creates a new path object.

The path is split on the forward slash (/) character into tokens; empty and redundant tokens are discarded. Enough context is kept to help the methods implemented in this module determine the nature of the path; if it is relative to root, prefixed with './', or relative to the "current working directory". An ARRAY reference blessed into this package's namespace is returned upon success. An EINVAL is thrown if the path provided is empty.



Return a list of the components parsed at object construction time.


Returns a string representation of the full path. This is the same as:

    join('/', @$path);

Returns a string representation of all of the leading path elements, of course save for the final path element.


Returns the final path component. If called with an extension, then the method will return the path component with the extension chopped off, if found.


Useful for iterating over the components of the path object. Shifts the internal start-of-array pointer by one, and returns the previous first value.


Push new components onto the current path object. Each part will be tokenized on the forward slash (/) character, and useless items will be discarded.


A new Filesys::POSIX::Path object is created based on $pathname, and the current path object's non-empty components are pushed onto that new instance. The new path object is returned.


A new Filesys::POSIX::Path object is created based on $pathname, and the new path object's non-empty components are pushed onto the current path object. The current $path reference is then returned.


Pops the final path component off of the path object list, and returns that value.


Returns the number of components in the current path object.


Returns true if the current path object represents an absolute path.


Written by Xan Tronix <xan@cpan.org>


Rikus Goodell <rikus.goodell@cpanel.net>
Brian Carlson <brian.carlson@cpanel.net>


Copyright (c) 2014, cPanel, Inc. Distributed under the terms of the Perl Artistic license.