段落の間にスペースがある場合:段落ごとにテキストを読み取り(set $/ = "\n\n"'
)、CPANのText::Autoformatを使用します。
例(DATAの代わりに通常のファイルハンドルを使用します-例では便宜上使用しただけです):
use strict;
use warnings;
use Text::Autoformat;
local $/ = "\n\n";
while (<DATA>) {
print autoformat $_, {left=>1, right=>80};
}
__DATA__
He watched Kahlan as she walked with her shoulders slumped
down.
He watched Kahlan as she walked with her shoulders slumped
down.
He watched Kahlan as she walked with her shoulders slumped
down.
He watched Kahlan as she walked with her shoulders slumped
down.
He watched Kahlan as she walked with her shoulders slumped
down.
He watched Kahlan as she walked with her shoulders slumped
down.
出力:
He watched Kahlan as she walked with her shoulders slumped down.
He watched Kahlan as she walked with her shoulders slumped down. He watched
Kahlan as she walked with her shoulders slumped down. He watched Kahlan as she
walked with her shoulders slumped down.
He watched Kahlan as she walked with her shoulders slumped down. He watched
Kahlan as she walked with her shoulders slumped down.