Skip to content

Instantly share code, notes, and snippets.

@fy2
Created July 6, 2022 10:57
Show Gist options
  • Save fy2/7cb841cb5d3ff0cf09213c254e2b8bd0 to your computer and use it in GitHub Desktop.
Save fy2/7cb841cb5d3ff0cf09213c254e2b8bd0 to your computer and use it in GitHub Desktop.
#!/opt/tools/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use Foo::Bar;
# Parse the command line options:
my %opt;
GetOptions(\%opt,
"help|h",
"man|m",
'option_a|a=s',
'option_b|b=s',
) || pod2usage(2);
pod2usage(1) if ($opt{help});
pod2usage(-exitval => 0, -verbose => 2) if ($opt{man});
my $foo = Foo::Bar->new(
{
lorem => $opt{option_a},
ipsum => $opt{option_b},
}
);
$foo->run();
__END__
=head1 NAME
foo.pl - A script to do xyz...
=head1 SYNOPSIS
foo.pl --option_a baz --option_b foobar
Options:
-help brief help message
-man detailed help message
-option_a sample sample sample
-option_b sample sample sample
=head1 OPTIONS
=over 8
=item B<-help>
Print a brief help message and exits.
=item B<-man>
Prints the (more detailed) manual page and exits.
=item B<-option_a>
Sample (... more detailed info if necessary)
=item B<-option_b>
Sample (... more detailed info if necessary)
=back
=head1 DESCRIPTION
B<foo.pl> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aenean facilisis rutrum magna a finibus. Orci varius natoque penatibus
et magnis dis parturient montes, nascetur ridiculus mus. Donec ut odio quis
nibh iaculis dictum. Suspendisse luctus bibendum finibus. Nam tempus
enim nulla, sed laoreet ex
=cut
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment