如何在 perl 中将参数从批处理文件传递到数组?



我是Perl的新手。你能给我建议将参数从批处理文件传递到 Perl 中的数组吗?还是可能?

批处理文件:

@echo off
C:Perl64binperl.exe D:perlprog.pl a 30 5 d o 78 g

并从 Perl 脚本中的数组中读取这些参数并打印在屏幕上:

($st, $st2, $com, $ep, $co, $vel, $sig) = @_;
print @_;

试试这个方式:

Sample.bat批处理文件内容:

perl -w d:testingSampleScript.pl %1 %2 %3

SampleScript.pl脚本内容:

my ($arg1, $arg2, $arg3) = @ARGV;
print "First Param... $arg1n";
print "Second Param... $arg2n";
print "Third Param... $arg3n";

在提示时:

$: Sample.bat Parrot Pigeon Duck

谢谢

最新更新