Parse-Path
view release on metacpan or search on metacpan
$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.
Normalization of splits
While "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 "as_string" method takes the hash steps and re-adds the
delimiters, per rules on the blueprint of the path class. (See
"delimiter_placement" in Parse::Path::Role::Path.)
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. Parse::Path handles this on all of
its paths, but it's something to be aware of if you create your own path
classes.
SEE ALSO
Data::SplitSerializer - Uses this module for path parsing
AVAILABILITY
The project homepage is <https://github.com/SineSwiper/Parse-Path/wiki>.
The latest version of this module is available from the Comprehensive
Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a
CPAN site near you, or see <https://metacpan.org/module/Parse::Path/>.
SUPPORT
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:
<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:
* irc.perl.org
You can connect to the server at 'irc.perl.org' and talk to this
person for help: SineSwiper.
Bugs / Feature Requests
Please report any bugs or feature requests via
<https://github.com/SineSwiper/Parse-Path/issues>.
AUTHOR
Brendan Byrd <bbyrd@cpan.org>
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)
( run in 2.476 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )