≡ Menu

Quick Command Line Arg parsing

To parse command line arguments passed to a script without using a module, parse @ARGV with the following:


foreach my $arg (@ARGV) {
    $a = 1, next if $arg eq '-a';
    $b = 1, next if $arg eq '-b';
    $c = 1, next if $arg eq '-c';
}

Note: This is good only for boolean (on/off) command line switches.

{ 0 comments… add one }

Leave a Comment