in reply to fixed length string

You can use substr to get parts of your string and the x operator to add missing parts.
my $max = 10; my $string = 'something'; $string = substr($string, 0, $max); my $length = length $string; $string .= ' ' x ( $max - $length ) if ( $length < $max );
Boris