my test.pl script as below.
#!C:\Perl\bin\perl.exe
use strict;
use warnings;
sub printargs
{
print "@_\n";
}
&printargs("hello", "world"); # Example prints "hello world"
If I replaced printargs("hello", "world"); with print($a, $b);.
How to pass ‘hello’ ,’world’ to $a , $b when I run perl test.pl hello world at command line, Thanks.
$ARGV[0] contains the first argument, $ARGV[1] contains the second argument, etc.
$#ARGV is the subscript of the last element of the @ARGV array, so the number of arguments on the command line is $#ARGV + 1.