-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreet.pm
More file actions
executable file
·50 lines (35 loc) · 808 Bytes
/
greet.pm
File metadata and controls
executable file
·50 lines (35 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env perl
package greet;
use strict;
use warnings;
use feature qw( say );
use Getopt::Long qw( GetOptionsFromArray );
use Pod::Usage;
sub main {
my ( $argv ) = @_;
my %opt;
GetOptionsFromArray( $argv, \%opt,
'greeting:s',
'help|h',
);
pod2usage(0) if $opt{help};
pod2usage("ERROR: Must give someone to greet") if !$argv->[0];
$opt{greeting} ||= "Hello";
say "$opt{greeting}, $argv->[0]!";
return 0;
}
exit main( \@ARGV ) if !caller(0);
1;
=head1 NAME
greet.pl - Say hello!
=head1 SYNOPSIS
perl greet.pl [--greeting <greeting>] [<who>]
perl -h|--help
=head1 ARGUMENTS
=head2 who
Who to greet. Defaults to "World".
=head1 OPTIONS
=head2 greeting
The greeting to use. Defaults to "Hello".
=head2 help|h
Display help and usage