Parse-Path
view release on metacpan or search on metacpan
lib/Parse/Path.pm view on Meta::CPAN
$path->shift; # now a dangling 'tmp/file.txt', tied to position 2
$path->unshift('/home/bbyrd');
$path->as_string; # /home/tmp/file.txt
This problem can be sidestepped by using the string forms:
$path->shift;
$path->shift; # tmp/file.txt
$path->replace( [ '/home/bbyrd', $path->as_string ] );
$path->as_string; # /home/bbyrd/tmp/file.txt
This may be fixed in a later release.
=head2 Normalization of splits
While L</auto_normalize> controls normalization of steps, delimiter normalization is still automatic. For example:
my $path = Parse::Path->new(
path => 'foo//////bar.txt',
style => 'File::Unix',
);
say $path->as_string; # foo/bar.txt
This is because delimiters are not actually stored anywhere after parsing. The L</as_string> method takes the hash steps and re-adds
the delimiters, per rules on the blueprint of the path class. (See L<Parse::Path::Role::Path/delimiter_placement>.)
=head2 Sparse arrays and memory usage
Since arrays within paths are based on indexes, there's a potential security issue with large indexes causing abnormal memory usage
with certain modules that would use these paths. In Perl, these two arrays would have drastically different memory footprints:
my @small;
$small[0] = 1;
my @large;
$large[999999] = 1;
This can be mitigated by making sure the Path style you use will limit the total digits for array indexes. L<Parse::Path> handles
this on all of its paths, but it's something to be aware of if you create your own path classes.
=head1 SEE ALSO
L<Data::SplitSerializer> - Uses this module for path parsing
=head1 AVAILABILITY
The project homepage is L<https://github.com/SineSwiper/Parse-Path/wiki>.
The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
site near you, or see L<https://metacpan.org/module/Parse::Path/>.
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
=head1 SUPPORT
=head2 Internet Relay Chat
You can get live help by using IRC ( Internet Relay Chat ). If you don't know what IRC is,
please read this excellent guide: L<http://en.wikipedia.org/wiki/Internet_Relay_Chat>. Please
be courteous and patient when talking to us, as we might be busy or sleeping! You can join
those networks/channels and get help:
=over 4
=item *
irc.perl.org
You can connect to the server at 'irc.perl.org' and talk to this person for help: SineSwiper.
=back
=head2 Bugs / Feature Requests
Please report any bugs or feature requests via L<https://github.com/SineSwiper/Parse-Path/issues>.
=head1 AUTHOR
Brendan Byrd <bbyrd@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Brendan Byrd.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
=cut
( run in 1.750 second using v1.01-cache-2.11-cpan-39bf76dae61 )