Module::Path::Simplify - Simplify absolute paths for pretty-printing.
version 0.001000
This module aids in simplifying paths to modules you may already have had lying around,
for instance, like in %INC
, and aids in compressing them into a format more easily skimmed,
for use in diagnostic reporting such as stack-traces, where legibility of the trace is more important
to you than being able to use path URIs
verbatim.
use Module::Path::Simplify;
my $simplifier = Module::Path::Simplify->new();
print $simplifier->simplify( $INC{'Module/Path/Simplify.pm'} )
# This may output something like $INC[0]/Module/Path/Simplify.pm
# or even ${VP} or ${SP}, depending on where you installed it.
print $simplifier->pp_aliases;
# This will emit a key => value table of all the aliases used so far
# by this instance, expanding the display setting of the alias to the path matched.
#
# In cases where the aliases are different to their display values for better compressability
# the raw internal alias names will be displayed in parentheses at the end of the line.
Create a simplifier
object.
Normally, new
captures the state of @INC
at its creation time.
This can be disabled to use a per-resolution dynamic @INC
via
->new( inc_dynamic => 1 );
Additionally, @INC
can be overridden with a custom list via
->new( inc => [ @INC ] );
inc_dynamic
and inc
don't work together, and setting inc_dynamic
will cause inc
to be ignored.
Return a simplified version of a path, or the path itself if there are no simplifications available
print $simpl->simplify( $INC{'Test/More.pm'} )
Returns the internal alias tracking object.
Return a string detailing the used simplification aliases and where they map to. ( And possibly their internal identifier )
Returns whether or not this simplifier is using a dynamic @INC
.
Returns the snapshot @INC
in use when not using inc_dynamic
Kent Fredric kentnl@cpan.org
This software is copyright (c) 2015 by Kent Fredric kentfredric@gmail.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.