Acme-TLDR
view release on metacpan or search on metacpan
lib/Acme/TLDR.pm view on Meta::CPAN
];
store $modules => $cache
unless exists $ENV{NOCACHE};
} 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);
}
}
return \%modules;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Acme::TLDR - Abbreviate Perl namespaces for the Extreme Perl Golf
=head1 VERSION
version 0.004
=head1 SYNOPSIS
#!/usr/bin/env perl
use strict;
use warnings;
use Acme::TLDR;
use D::D; # Data::Dump
use D::MD5; # Digest::MD5
use DT; # DateTime
use HTTP::T; # HTTP::Tiny
print DT->now, "\n";
my $ua = HTTP::T->new;
my $res = $ua->get('http://ifconfig.me/all');
dd $res;
my $md5 = D::MD5->new;
$md5->add($res->{content});
print $md5->hexdigest, "\n";
=head1 DESCRIPTION
This module is heavily inspired on the
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
is initialized upon L<Acme::TLDR> start.
It is updated when the F<perllocal.pod> file of the used Perl version gets a modified time more recent than the cache file itself.
=head1 SEE ALSO
=over 4
=item *
L<App::p>
=item *
L<L>
=back
=head1 AUTHOR
Stanislaw Pusep <stas@sysd.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Stanislaw Pusep.
( run in 0.401 second using v1.01-cache-2.11-cpan-5511b514fd6 )