Lesson 47 of 55
8 mins readPython CLI Arguments (@ARGV) & Environment (%ENV)
In Plain English
Perl stores command-line arguments in `@ARGV` (0-indexed without script name) and system environment variables in the `%ENV` special hash.
Deep Dive: How It Works
@ARGV Array: Holds all CLI arguments passed to the script ($ARGV[0] is the first option).
%ENV Hash: Key-value map of environment variables (e.g., `$ENV{USER}`, `$ENV{PATH}`).
$0 Special Variable: Holds the name/path of the currently running Perl script.
Core Rules to Remember

@ARGV for CLI Arguments: List of parameters passed on invocation.

%ENV for System Environment: Read and write environment variables via `$ENV{VAR_NAME}`.
Live Interactive Example
Hit Run Code to see it liveReading Arguments and Environment
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Output Console
Click "Run Code" to view the rendered output.
How it works: Inspected arguments and read the %ENV hash.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Read Environment Setting
Set `$ENV{SERVICE_TIER} = "Enterprise";`
Print `"Active Tier: $ENV{SERVICE_TIER}\n"`.
1
2
3
4
5
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.