配列に文字列があり、それをファイルに書き込みたい。問題は、100文字に制限された数の文字を書く必要があり、その後、行に戻って文の内容を終了する必要があることです. その後、再び 100 文字になった場合は、テーブル内のチェーン コンテンツを終了するまで、その行に戻ります。
2 に答える
1
モジュールはあなたが望むことをする可能性が高く、Text::Wrap
コア Perl の一部であるため、インストールする必要はありません。
DATA
このプログラムは、疑似ハンドルからテキストを読み取り、再フォーマットします。
use strict;
use warnings;
use Text::Wrap;
my @text = <DATA>;
chomp @text;
$Text::Wrap::columns = 100;
print Text::Wrap::wrap '', '', @text;
__DATA__
"Text::Wrap::wrap()" is a very simple paragraph formatter. It formats a
single paragraph at a time by breaking lines at word boundaries.
Indentation is controlled for the first line ($initial_tab) and all
subsequent lines ($subsequent_tab) independently. Please note:
$initial_tab and $subsequent_tab are the literal strings that will be
used: it is unlikely you would want to pass in a number.
Text::Wrap::fill() is a simple multi-paragraph formatter. It formats
each paragraph separately and then joins them together when it's done.
It will destroy any whitespace in the original text. It breaks text into
paragraphs by looking for whitespace after a newline. In other respects
it acts like wrap().
Both "wrap()" and "fill()" return a single string.
出力
"Text::Wrap::wrap()" is a very simple paragraph formatter. It formats a single paragraph at a time
by breaking lines at word boundaries. Indentation is controlled for the first line ($initial_tab)
and all subsequent lines ($subsequent_tab) independently. Please note: $initial_tab and
$subsequent_tab are the literal strings that will be used: it is unlikely you would want to pass in
a number. Text::Wrap::fill() is a simple multi-paragraph formatter. It formats each paragraph
separately and then joins them together when it's done. It will destroy any whitespace in the
original text. It breaks text into paragraphs by looking for whitespace after a newline. In other
respects it acts like wrap(). Both "wrap()" and "fill()" return a single string.
于 2012-04-11T15:40:41.383 に答える
0
Text::ReformやText::Autoformatのようなものを探していると思います。
于 2012-04-11T14:23:27.003 に答える