handle the command line arguments


/ Published in: Perl
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #--------------------------------------------------------------------------
  2. # handle the command line arguments
  3. #
  4. if ( $#ARGV == -1)
  5. {
  6. &usage;
  7. exit 0;
  8. }
  9.  
  10. while (@ARGV)
  11. {
  12. $argument = shift(@ARGV);
  13.  
  14. if ($argument eq "-HELP" || $argument eq "-H")
  15. {
  16. &usage;
  17. exit 0;
  18. }
  19. elsif ($argument eq "-file" || $argument eq "-f")
  20. {
  21. $file = shift(@ARGV);
  22. }
  23. elsif ($argument eq "-verbose" || $argument eq "-v")
  24. {
  25. # input data come live from the specified htget output file. Faster.
  26. $verbose = 1;
  27. }
  28. elsif ($argument eq "-DEBUG")
  29. {
  30. $DEBUG_LEVEL = shift(@ARGV);
  31. }
  32. elsif ($argument eq "-DOCUMENT" || $argument eq "-D")
  33. {
  34. &document;
  35. exit 0;
  36. }
  37. elsif ($argument eq "-ABOUT" || $argument eq "-A")
  38. {
  39. &about;
  40. exit 0;
  41. }
  42. elsif ($argument eq "-REL_NOTES" || $argument eq "-R")
  43. {
  44. &rel_notes;
  45. exit 0;
  46. }
  47. else
  48. {
  49. print "ERROR: unknown argument '$argument'.\n";
  50. &usage;
  51. exit 0;
  52. }
  53. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.