param1.pl 714 B

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