Skip to content

Instantly share code, notes, and snippets.

@GoldsteinE
Created April 2, 2021 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoldsteinE/a84564ad54eeef71b5e4369d2e2bc775 to your computer and use it in GitHub Desktop.
Save GoldsteinE/a84564ad54eeef71b5e4369d2e2bc775 to your computer and use it in GitHub Desktop.
use v5.18;
use strict;
use warnings;
use diagnostics;
use Getopt::Long;
sub must($$) {
my ($name, $val) = @_;
die "You must pass --$name\n" unless defined $val;
}
sub main() {
GetOptions(
'host=s', \my $host,
'port=i', \my $port,
);
must "host", $host;
must "port", $port;
say "Host: $host";
say "Port: $port";
say "Positional args ", join ' ', @ARGV;
}
main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment