Acme-TLDR
view release on metacpan or search on metacpan
DESCRIPTION
This module is heavily inspired on the shortener module proposal
<http://mail.pm.org/pipermail/rio-pm/2012q2/009177.html> by Fernando
Correa de Oliveira <https://metacpan.org/author/FCO>, albeit it
operates in a completely distinct way.
ENVIRONMENT VARIABLES
* DEBUG - when set, dump the internals status (most importantly, the
long <=> short name mapping;
* NOCACHE - when set, no persistent cache is saved.
CAVEAT
To reduce loading time (ExtUtils::Installed->new->modules is too damn
slow), an installed module cache is initialized upon Acme::TLDR start.
It is updated when the perllocal.pod file of the used Perl version gets
a modified time more recent than the cache file itself.
lib/Acme/TLDR.pm view on Meta::CPAN
);
_debug(q(ExtUtils::Installed cache: %s), $cache);
my $updated = -M $cache;
my $modules;
if (
not defined $updated
or
grep { -e and -M _ < $updated }
map { catfile($_, q(perllocal.pod)) }
@INC
) {
## no critic (ProhibitPackageVars)
_debug(q(no cache found; generating));
$modules = [
uniq
keys %{$Module::CoreList::version{$]}},
ExtUtils::Installed->new->modules,
];
store $modules => $cache
lib/Acme/TLDR.pm view on Meta::CPAN
} else {
_debug(q(reading from cache));
$modules = retrieve $cache;
}
return $modules;
}
sub _shorten {
my ($modules) = @_;
my %collisions = map { $_ => 1 } @{$modules};
my %modules;
for my $long (sort @{$modules}) {
my @parts = split /\b|(?=[A-Z0-9])/x, $long;
next unless $#parts;
my $short = join q() => map { /^(\w)\w{3,}$/x ? $1 : $_ } @parts;
next if $short eq $long;
unless (exists $collisions{$short}) {
++$collisions{$short};
$modules{$long} = $short;
_debug(q(%-64s => %s), $long, $short);
} else {
_debug(q(%-64s => *undef*), $long);
}
}
lib/Acme/TLDR.pm view on Meta::CPAN
L<shortener module proposal|http://mail.pm.org/pipermail/rio-pm/2012q2/009177.html>
by L<Fernando Correa de Oliveira|https://metacpan.org/author/FCO>,
albeit it operates in a completely distinct way.
=head1 ENVIRONMENT VARIABLES
=over 4
=item *
C<DEBUG> - when set, dump the internals status (most importantly, the long <=> short name mapping;
=item *
C<NOCACHE> - when set, no persistent cache is saved.
=back
=head1 CAVEAT
To reduce loading time (C<ExtUtils::Installed-E<gt>new-E<gt>modules> is too damn slow), an installed module cache
( run in 0.303 second using v1.01-cache-2.11-cpan-65fba6d93b7 )