[英]how to send stdin into perl program by batch file?
我想將許多文件/字符串處理到perl中,不要等待stdin從批處理文件響應,批處理文件將如何?
例如我有test.pl和內容是
my $o=<STDIN>;
print "$o\n";
my $c=<STDIN>;
print "$c\n";
批處理文件可以隨時使用不同的stdin執行test.pl
考慮到批處理文件的功能是
perl test.pl <stdin> <stdin>
perl test.pl <stdin> <stdin>
perl test.pl <stdin> <stdin>
perl test.pl <stdin> <stdin>
然后我想知道如何將標准輸入發送到test.pl。
在這里,您必須使用@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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.