Package::Abbreviate - shorten package names
use Package::Abbreviate; my $pkg = "Foo::Bar::TooLong::PackageName"; # no need to abbreviate! my $p = Package::Abbreviate->new(30); printf '%30s', $p->abbr($pkg); # Foo::Bar::TooLong::PackageName # a bit shorter my $p = Package::Abbreviate->new(28); printf '%28s', $p->abbr($pkg); # F::Bar::TooLong::PackageName # even shorter my $p = Package::Abbreviate->new(24); printf '%24s', $p->abbr($pkg); # F::B::TL::PackageName # even! ...oops my $p = Package::Abbreviate->new(20); printf '%20s', $p->abbr($pkg); # spits a warning # we can do it more eagerly with an option my $p = Package::Abbreviate->new(20, {eager => 1}); printf '%20s', $p->abbr($pkg); # FB::TL::PackageName # more eagerly my $p = Package::Abbreviate->new(16, {eager => 1}); printf '%16s', $p->abbr($pkg); # F::B::TL::PN # even more! my $p = Package::Abbreviate->new(10, {eager => 1}); printf '%10s', $p->abbr($pkg); # FBTLPN # oops, there's nothing left to cut... my $p = Package::Abbreviate->new(5, {eager => 1}); printf '%5s', $p->abbr($pkg); # spits a warning
When you make a big table that contains a lot of data with (long) package names, you might want to shorten some of them. However, just trimming them with sprintf or substr may not work for you.
sprintf
substr
Package::Abbreviate shortens package names, but also tries not to do too much.
takes a max length of abbreviations, and an optional hash reference to configure.
lets Package::Abbreviate to shorten the basename and/or omit colons between monikers.
croaks if an error occurs.
takes one or more package names and returns shortened ones.
If you pass more than one package names, Package::Abbreviate also tests if duplicated names are not generated.
Lingua::Abbreviate::Hierarchy
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2014 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Package::Abbreviate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Package::Abbreviate
CPAN shell
perl -MCPAN -e shell install Package::Abbreviate
For more information on module installation, please visit the detailed CPAN module installation guide.