2

I am new in Perl. Could you please give me advice to pass parameters from batch file to the array in Perl? Or is it possible?

Batch file:

@echo off
C:\Perl64\bin\perl.exe D:\perl\prog.pl a 30 5 d o 78 g

and read these parameters from the array in Perl script and print on the screen:

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

print @_;
2
  • You can use %1 .. %n parameters Commented May 19, 2020 at 11:11
  • 3
    @_ is for a sub's parameters. The script's parameters are found in @ARGV Commented May 19, 2020 at 12:17

1 Answer 1

3

Try this way:

Sample.bat Batch File contents:

perl -w d:\testing\SampleScript.pl %1 %2 %3

SampleScript.pl Script contents:

my ($arg1, $arg2, $arg3) = @ARGV;

print "First Param... $arg1\n";

print "Second Param... $arg2\n";

print "Third Param... $arg3\n";

On your Prompt:

$: Sample.bat Parrot Pigeon Duck

Thanks

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.