NAME
String::Truncate - a module for when strings are too long to be displayed in...
VERSION
version 0.02
SYNOPSIS
This module handles the simple but common problem of long strings and finite terminal width. It can convert:
"this is your brain" -> "this is your ..."
or "...is your brain"
or "this is... brain"
or "... is your b..."
It's simple:
use String::Truncate qw(elide);
my $brain = "this is your brain";
elide($brain, 16); # first option
elide($brain, 16, { truncate => 'left' }); # second option
elide($brain, 16, { truncate => 'middle' }); # third option
elide($brain, 16, { truncate => 'ends' }); # fourth option
FUNCTIONS
elide($string, $length, \%arg)
This function returns the string, if it is less than or equal to $length
characters long. If it is longer, it truncates the string and marks the elision.
Valid arguments are:
elide - elide at left, right, middle, or ends? (default: right)
marker - how to mark the elision (default: ...)
trunc($string, $length, \%arg)
This acts just like elide
, but assumes an empty marker, so it actually truncates the string normally.
SEE ALSO
Text::Truncate does a very similar thing, and lets you set the default marker, rather than specify one every time if you don't want "..."
AUTHOR
Ricardo Signes, <rjbs at cpan.org>
BUGS
Please report any bugs or feature requests to bug-string-truncate@rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=String-Truncate. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
ACKNOWLEDGEMENTS
Ian Langworth gave me some good advice about naming things. (Also some bad jokes. Nobody wants String::ETOOLONG, Ian.)
COPYRIGHT & LICENSE
Copyright 2005 Ricardo Signes, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.