my $string1 = "cherry"; my $string2 = "a red fruit"; my $spaces = 30 - length($string1); my $text = sprintf("%-${spaces}s\%s\%s",$string1,$string2);