私があなたの問題を正しく理解していれば、Text::Wrap は (不当ではなく) 文字列の先頭にある余分な空白を削除しています。あなたはそれが起こることを望まない
これは、行頭のスペースをアンダースコアに置き換え、wrap() を介して実行し、アンダースコアを削除するためのソリューションです。
use Text::Wrap;
#test data, note the 5 spaces at the start of some lines
for (1..4) { push @a," hello I love you", "Won't you tell me your name? ";}
push @a,"She's walking down the street"," Blind to every eye she meets","Do you think you\'ll be the guy", "To make the queen of the angels sigh?";
#make it longer with repeating
push @b,@a,@a,@a;
$Text::Wrap::columns = 44;
#show bad behaviour
print "VERSION 1\n";
print wrap("","",@b);
#fixup strings with leading underscores
map {s/^\s+/"_" x length(\1)/e} @b;
@z=wrap("","",@b);
#remove _
map{s/_+/" " x length(\1)/ge} @z;
print "\nVERSION 2\n";
print @z;