Created
May 2, 2015 13:16
-
-
Save dgoade/c104ff00ff65c0266512 to your computer and use it in GitHub Desktop.
Automation Scripting Essentials, Perl: Getopt::Long
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
# Automation Scripting Essential Skills (https://github.com/dgoade/ase) | |
# Perl | |
# Input: Parsing command-line parameters | |
# Technique #1 -- Use getopt or getoptlong | |
use Getopt::Long; | |
our $Action; | |
our $Help; | |
our $LogLevel; | |
our $NoOp; | |
our $Verbose; | |
GetOptions ( | |
"a|action=s" => \$Action, | |
"h|help" => \$Help, | |
"l|loglevel=s" => \$LogLevel, | |
"n|noop" => \$NoOp, | |
"v|verbose" => \$Verbose | |
); | |
print "Parameters you passed:\n"; | |
print "action=$Action\n"; | |
print "help=$Help\n"; | |
print "loglevel=$LogLevel\n"; | |
print "noop=$NoOp\n"; | |
print "verbose=$Verbose\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment