NAME

String::ShortenHostname - tries to shorten hostnames while keeping them meaningful

SYNOPSIS

use String::ShortenHostname;

$sh = String::ShortenHostname->new( length => 20, keep_digits_per_domain => 3 );
$sh->shorten('zumsel.haushaltswarenabteilung.einzelhandel.de');
# zumsel.hau.ein.de
$sh->keep_digits_per_domain(5);
$sh->shorten('zumsel.haushaltswarenabteilung.einzelhandel.de');
# zumsel.haush.einze.de

$sh->keep_digits_per_domain(3);
$sh->shorten('verylonghostnamepartcannotbeshortend.some-domain.de');
# verylonghostnamepartcannotbeshortend.som.de -> still 43 chars 

$sh->force(1);
$sh->shorten('verylonghostnamepartcannotbeshortend.some-domain.de');
# verylonghostnamepart

$sh->force_edge('~');
$sh->shorten('verylonghostnamepartcannotbeshortend.some-domain.de');
# verylonghostnamepar~

DESCRIPTION

String::ShortenHostname will try to shorten the hostname string to the length specified. It will cut each domain part to a given length from right to left till the string is short enough or the end of the domain has been reached.

Options:

length (required)

The desired maximum length of the hostname string.

keep_digits_per_domain (default: 3)

Cut each domain part at this length.

force (default: 0)

If specified the module will force the length by cutting the result string.

force_edge (default: undef)

If defined this string will be used to replace the end of the string to indicate that it was truncated.

COPYRIGHT

Copyright 2014 Markus Benning <me@w3r3wolf.de>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.