- 1 year ago
Executing Perl script from windows-command line with 2 entry
To execute a Perl script from the Windows command line with two entry parameters, follow these steps:
Open the Windows Command Prompt (cmd.exe).
Navigate to the directory where your Perl script is located. For example, if your Perl script is named
script.pl
and located inC:\Scripts
, use the following command to change the directory:
cmdcd C:\Scripts
- Execute the Perl script by providing the two entry parameters after the script name. For example, if your script expects two parameters named
param1
andparam2
, use the following command:
cmdperl script.pl param1 param2
Replace script.pl
, param1
, and param2
with the actual names of your Perl script and the two parameters you want to pass to the script.
In your Perl script, you can access the two entry parameters using the @ARGV
array. Here's an example of how to retrieve and use the parameters in the Perl script:
perl# script.pl
use strict;
use warnings;
# Check if two parameters are provided
if (@ARGV < 2) {
die "Usage: perl script.pl param1 param2\n";
}
# Get the two entry parameters
my $param1 = $ARGV[0];
my $param2 = $ARGV[1];
# Print the parameters
print "Parameter 1: $param1\n";
print "Parameter 2: $param2\n";
When you run the Perl script from the Windows command line as shown above, it will display the values of param1
and param2
that you passed as command-line arguments.
Remember that you need to have Perl installed on your Windows system and included in the system's PATH environment variable to execute Perl scripts from the command line.