-
-
Save GoldsteinE/a84564ad54eeef71b5e4369d2e2bc775 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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