NAME

Maplat::Helpers::Strings - special string handling functions

SYNOPSIS

use Maplat::Helpers::Strings qw(tabsToTable normalizeString);

my $tableline = tabsToTable($text, @lengths);
my $newstring = normalizeString($text);

DESCRIPTION

This module is home to some specialized functions for modifying strings. Most people wont need this but i find them rather helpfull in some cases.

tabsToTable

This function turns a tab delimated text string into a space-padded line suitable for printing ascii-art tables.

Takes two arguments, a $textstring with multiple fields delimated by tabs, and an array with field lengths. The second argument is an array of desired field lengths.

Example:

my @length = (5, 8, 7);
my @spies = ("007\tBond\tJames", "008\tDoe\tJohn");
...
foreach my $spy (@spies) {
  print tabsToTable($spy);
}

Prints out:

007  Bond    James
008  Doe     John

normalizeString

Removed unneeded whitespaces as well as all other non-word characters from a string.

Takes one argument, a text string and returns a "normalized" version of this string.

AUTHOR

Rene Schickbauer, <rene.schickbauer@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008-2010 by Rene Schickbauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.