@ARGV and %ENV

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

unix% perl -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


use strict;

my $column=$ARGV[0];

my $database=$ARGV[1];

------run the program now---

$./ 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 😉