Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use warnings;
- use strict;
- # write the 'Hello World' program with help, a version identifier and internationalization
- use Getopt::Std;
- my %options;
- # the 'getopts' subroutine takes as arguments a specification (the letters we want to know about)
- # and a hash which will store the values for the letters
- getopts("vhl:",\%options);
- if ($options{v}) {
- print "Hello World, version 3.\n";
- exit;
- } elsif ($options{h}) {
- print <<EOF;
- $0: Typical Hello World program
- Syntax: $0 [-v|-h|-l <language>]
- -h : This help message
- -v : Print version on standard output and exit
- -l : Turn on international language support
- EOF
- exit;
- } elsif ($options{l}) {
- if ($options{l} eq "french") {
- print "Bonjour, tout le monde.\n";
- } else {
- die "$0: unsupported language\n";
- }
- } else {
- print "Hello, world.\n";
- }
Add Comment
Please, Sign In to add comment