Perl不能正确打印 [英] Perl not printing properly
问题描述
Has MySQL,安装:,然后执行该命令,然后打印确定。我已经尝试使用睡眠并尝试清除$ ssh_d对象。任何意见赞赏。不要担心在这个特定的子变量,这个问题正在发生。感谢你们。
if($ MySQL)
{
print有MySQL,正在安装:;
$ mysqlCmd =/path/to/script/mysql-install.pl $ person> / dev / null 2>& 1;
$ ssh_d-> cmd($ mysqlCmd);
打印OK\\\
;
STDOUT通常是行缓冲,所以在打印换行符之前你不会看到你的输出。在打印之前,您可以设置 $ |
强制您的输出被打印。
要在每次打印后打开自动清理,请将 $ |
设置为1: / p>
$ | = 1;
print输入3到5之间的数字:;
chomp(my $ answer =< STDIN>);
(请注意,$ |实际上并不是单个值,它会针对每个文件句柄分别进行跟踪。设置它时,会影响当前所选文件句柄的设置(请参阅 选择
)。
Ok, so I have some sub routines similar to what you see below, my issue is that the print function is not printing out until the actual command is complete, I want it to print
"Has MySQL, Installing:", and then do the command then print OK. I have already tried using sleep and tried clearing the $ssh_d object. Any advice appreciated. Don't worry about the variables in this particular sub, the issue is happening all over. Thanks guys.
if ($MySQL)
{
print "Has MySQL, Installing: ";
$mysqlCmd = "/path/to/script/mysql-install.pl $person > /dev/null 2>&1";
$ssh_d->cmd("$mysqlCmd");
print "OK\n";
}
STDOUT is usually line-buffered, so you won't see your output until you print a newline. You can set $|
before printing to force your output to be printed.
To turn on autoflushing after each print, set $|
to 1:
$| = 1;
print "Enter a number between 3 and 5: ";
chomp( my $answer = <STDIN> );
(Note that $| isn't actually a single value, it is tracked separately for each filehandle. When you set it, it affects the setting for the currently selected filehandle (see select
).
这篇关于Perl不能正确打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!