Perl ARGV

@ARGV and %ENV

The built-in array @ARGV contains the command line arguments for a Perl program. The following run of the Perl program critic.pl will have the ARGV array (“-poetry”, “poem.txt”).

unix% perl critic.pl -poetry poem.txt

%ENV contains the environment variables of the context that launched the Perl program.

@ARGV and %ENV make the most sense in a Unix environment.

So for example you have a script like test.pl

  #!/usr/bin/perl  use strict;  my $column=$ARGV[0];  my $database=$ARGV[1];    ------run the program now---  $./test.pl ssn employees  

in above example we are passing two values as commandline arguments. so $column will have “ssn” and $database will have “employees”.
Note: Pass values in quoutes if values have spaces.

If you have found my website useful, please consider buying me a coffee below 😉