2016-01-30 135 views
1

我想處理許多文件/字符串到Perl中,不要等待stdin從批處理文件中作出響應。怎樣才能批處理文件?如何通過批處理文件發送stdin到perl程序?

比如我有test.pl,內容是

my $o=<STDIN>; 

print "$o\n"; 

my $c=<STDIN>; 

print "$c\n"; 

而且一個批處理文件在任何時間執行不同的標準輸入test.pl

認爲批處理文件的功能將是

perl test.pl <stdin> <stdin> 
perl test.pl <stdin> <stdin> 
perl test.pl <stdin> <stdin> 
perl test.pl <stdin> <stdin> 

那麼我想知道如何將標準輸入發送到test.pl.

回答

1

在這裏你必須使用@ARGV接收數據。它應該是如下:

my $o=$ARGV[0]; 

print "$o\n"; 

my $c=$ARGV[1]; 

print "$c\n"; 

可以執行程序如下:

perl test.pl argument_1a argument_2a 

你會得到輸出作爲

argument_1a 
argument_2a 
相關問題