My linux world » Perl – Check Command line parameters

Perl - Check Command line parameters


Arguments are stored in $ARGV tab.

use strict;
use warnings;
 
# count number of parameters :
my $nbParameters = @ARGV;
 
# get parameters:
my param1 = $ARGV[0];
my param2 = $ARGV[1];
(...)
my paramN = $ARGV[N-1];
 
# print usage :
if(@ARGV != 0) {
  die "Usage $0\n";
}

Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.