1234567891011121314151617181920212223242526272829303132 |
- #!/usr/bin/env perl
- # Perl parameter example with Getopt::Long.
- # License: CC0
- # Usage:
- # ./param1.pl 'some test text'
- # To handle CLI parameters
- use Getopt::Long;
- # Shows up when --help or -h is passed
- sub help_text {
- print("usage: param1.pl [-h] [TEXT]
- Prints the text that is passed to it.
- optional arguments:
- -h, --help show this help message and exit\n");
- exit;
- }
- # An example subroutine that just prints whatever is passed to it.
- sub printit {
- print(shift . "\n");
- }
- # Process CLI parameters and update config values as necessary
- GetOptions ('<>' => \&printit,
- "h|help" => \&help_text)
- or die("Error in command line arguments. Please review and try again.\n");
|