#---------------------------------------------------------------------
# LPad
#---------------------------------------------------------------------
# Pads a string on the left end to a specified length with a specified
# character and returns the result. Default pad char is space.
#---------------------------------------------------------------------
sub LPad {
local($str, $len, $chr) = @_;
$chr = " " unless (defined($chr));
return substr(($chr x $len) . $str, -1 * $len, $len);
} # LPad
#---------------------------------------------------------------------
# RPad
#---------------------------------------------------------------------
# Pads a string on the right end to a specified length with a specified
# character and returns the result. Default pad char is space.
#---------------------------------------------------------------------
sub RPad {
local($str, $len, $chr) = @_;
$chr = " " unless (defined($chr));
return substr($str . ($chr x $len), 0, $len);
} # RPad
#---------------------------------------------------------------------