【发布时间】:2011-01-29 18:10:53
【问题描述】:
!/usr/bin/env perl
use warnings;
use strict;
my $text = 'hello ' x 30;
printf "%-20s : %s\n", 'very important text', $text;
这个脚本的输出看起来更像是这样:
very important text : hello hello hello hello
hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello
...
但我想要这样的输出:
very important text: hello hello hello hello
hello hello hello hello
hello hello hello hello
...
我忘了说:文本应该有一个开放端,即文本行的右端应该与终端的大小相对应。
如何更改脚本以实现目标?
【问题讨论】:
-
你说的是完全合理的段落吗?在终端上这将是既困难又丑陋的。我猜你从来没有在 CPM 上与 WordStar 合作过。