Guest User

Untitled

a guest
Feb 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4.  
  5. # write the 'Hello World' program with help, a version identifier and internationalization
  6.  
  7. use Getopt::Std;
  8. my %options;
  9. # the 'getopts' subroutine takes as arguments a specification (the letters we want to know about)
  10. # and a hash which will store the values for the letters
  11. getopts("vhl:",\%options);
  12.  
  13. if ($options{v}) {
  14. print "Hello World, version 3.\n";
  15. exit;
  16. } elsif ($options{h}) {
  17. print <<EOF;
  18.  
  19. $0: Typical Hello World program
  20.  
  21. Syntax: $0 [-v|-h|-l <language>]
  22.  
  23. -h : This help message
  24. -v : Print version on standard output and exit
  25. -l : Turn on international language support
  26. EOF
  27. exit;
  28. } elsif ($options{l}) {
  29. if ($options{l} eq "french") {
  30. print "Bonjour, tout le monde.\n";
  31. } else {
  32. die "$0: unsupported language\n";
  33. }
  34. } else {
  35. print "Hello, world.\n";
  36. }
Add Comment
Please, Sign In to add comment