http://www.perlmonks.org?node_id=106035


in reply to substr and strings on the outside

Hello,
I'm not sure I perfectly understood what you wanted to do. Do you want to append '12345' to the $f variable, with at least 5 spaces at the beginning?

If so, here's a snippet that should do what you want:

sub pad { my ($spaces, $string) = @_; return( " " x (5 - length $spaces) . $string ); } my $add = "12345"; my $f = " " x 4; # for leading spaces smaller than 5 print "[" . pad( $f, '12345') . "]";
<kbd>--
my $OeufMayo = new PerlMonger::Paris({http => 'paris.mongueurs.net'});</kbd>