CGI打印问题
CGI Printing issue
#!/usr/bin/perl -w
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);
use strict;
print "Content-type: text/plain\n";
print "\n";
my $date = system('date');
print "Date :: $date";
以上代码不断产生 Date :: 0
的输出而不是当前日期。
我找不到解决这个问题的方法。请帮忙
return 值 system command is the return value of the call. For a successful call this will be 0. If you want to capture the output of a command use backticks or IPC. Look at this answer: Capture the output of Perl system()
my $date = `date`;
print "Date :: $date";
但最好使用 DateTime。
不使用 system
命令,而是使用 backtick
。 system
命令不会 return 变量中的值。更改此行:
my $date = system('date');
到
my $date = `date`;
查看此内容以进一步了解 system
和 backtick
:
#!/usr/bin/perl -w
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);
use strict;
print "Content-type: text/plain\n";
print "\n";
my $date = system('date');
print "Date :: $date";
以上代码不断产生 Date :: 0
的输出而不是当前日期。
我找不到解决这个问题的方法。请帮忙
return 值 system command is the return value of the call. For a successful call this will be 0. If you want to capture the output of a command use backticks or IPC. Look at this answer: Capture the output of Perl system()
my $date = `date`;
print "Date :: $date";
但最好使用 DateTime。
不使用 system
命令,而是使用 backtick
。 system
命令不会 return 变量中的值。更改此行:
my $date = system('date');
到
my $date = `date`;
查看此内容以进一步了解 system
和 backtick
: