Maplat::Helpers::Padding - string padding/trimming helpers
use Maplat::Helpers::Padding qw(doFPad doSpacePad trim); # front pad string with zeroes my $padded = doFPad("100", 10); # pad string with spaces my $padded = doSpacePad("Hello World", 20); # trim start and end whitespace my $trimmed = trim(" Hello, world! ");
This module provides a few string padding and trimming helpers, used throughout the MAPLAT framework.
Takes two arguments, $text and $length and returns the padded string.
$text is the string to be padded to the desired $length with zeroes in front.
my $padded = doFPad("100", 5); # returns "00100"
$text is the string to be padded to the desired $length with spaces at the end.
my $padded = doSpacePad("100", 5); # returns "100 "
Takes one argument, the string to be trimmed. Returns the string with whitespace remoned from start and end of that string.
my $trimmed = trim(" test "); # returns "test"
Rene Schickbauer, <rene.schickbauer@gmail.com>
Copyright (C) 2008-2011 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.
To install Maplat, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Maplat
CPAN shell
perl -MCPAN -e shell install Maplat
For more information on module installation, please visit the detailed CPAN module installation guide.