package Path::Abstract; use warnings; use strict; =head1 NAME Path::Abstract - Fast and featureful UNIX-style path manipulation =head1 VERSION Version 0.093 =head1 SYNOPSIS use Path::Abstract; my $path = Path::Abstract->new("/apple/banana"); # $parent is "/apple" my $parent = $path->parent; # $cherry is "/apple/banana/cherry.txt" my $cherry = $path->child("cherry.txt"); =cut our $VERSION = '0.093'; use Sub::Exporter -setup => { exports => [ path => sub { sub { return __PACKAGE__->new(@_) } } ], }; use overload '""' => 'get', fallback => 1, ; use base qw/Path::Abstract::Underload/; =head1 METHODS =head2 Path::Abstract->new( ) =head2 Path::Abstract->new( , [ , ..., ] ) Create a new C object using or by joining each with "/" Returns the new C object =head2 Path::Abstract::path( ) =head2 Path::Abstract::path( , [ , ..., ] ) Create a new C object using or by joining each with "/" Returns the new C object =head2 $path->clone Returns an exact copy of $path =head2 $path->set( ) =head2 $path->set( , [ , ..., ] ) Set the path of $path to or the concatenation of each (separated by "/") Returns $path =head2 $path->is_nil =head2 $path->is_empty Returns true if $path is equal to "" =head2 $path->is_root Returns true if $path is equal to "/" =head2 $path->is_tree Returns true if $path begins with "/" path("/a/b")->is_tree # Returns true path("c/d")->is_tree # Returns false =head2 $path->is_branch Returns true if $path does NOT begin with a "/" path("c/d")->is_branch # Returns true path("/a/b")->is_branch # Returns false =head2 $path->to_tree Change $path by prefixing a "/" if it doesn't have one already Returns $path =head2 $path->to_branch Change $path by removing a leading "/" if it has one Returns $path =head2 $path->list =head2 $path->split Returns the path in list form by splitting at each "/" path("c/d")->list # Returns ("c", "d") path("/a/b/")->last # Returns ("a", "b") =head2 $path->first Returns the first part of $path up to the first "/" (but not including the leading slash, if any) path("c/d")->first # Returns "c" path("/a/b")->first # Returns "a" =head2 $path->last Returns the last part of $path up to the last "/" path("c/d")->last # Returns "d" path("/a/b/")->last # Returns "b" =head2 $path->get =head2 $path->stringify Returns the path in string or scalar form path("c/d")->get # Returns "c/d" =head2 $path->push( , [ , ..., ] ) =head2 $path->down( , [ , ..., ] ) Modify $path by appending each to the end of \$path, separated by "/" Returns $path =head2 $path->child( , [ , ..., ] ) Make a copy of $path and push each to the end of the new path. Returns the new child path =head2 $path->pop( ) Modify $path by removing parts from the end of $path Returns the removed path as a C object =head2 $path->up( ) Modify $path by removing parts from the end of $path Returns $path =head2 $path->parent( ) Make a copy of $path and pop parts from the end of the new path Returns the new parent path =head2 $path->dir =head2 $path->dir( , [ , ..., ] ) Create a new C object using $path as a base, and optionally extending it by each Returns the new dir object =head2 $path->file =head2 $path->file( , [ , ..., ] ) Create a new C object using $path as a base, and optionally extending it by each Returns the new file object =head1 SEE ALSO L L L =head1 AUTHOR Robert Krimen, C<< >> =head1 SOURCE You can contribute or fork this project via GitHub: L git clone git://github.com/robertkrimen/path-abstract.git Path-Abstract =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Path::Abstract You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS Thanks to Joshua ben Jore, Max Kanat-Alexander, and Scott McWhirter for discovering the "use overload ..." slowdown issue. =head1 COPYRIGHT & LICENSE Copyright 2007 Robert Krimen, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of Path::Abstract