Skip to content

Instantly share code, notes, and snippets.

@vyuh
Created May 8, 2022 12:09
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 vyuh/00453cb3fe90d6d4057a4ccf2328d33d to your computer and use it in GitHub Desktop.
Save vyuh/00453cb3fe90d6d4057a4ccf2328d33d to your computer and use it in GitHub Desktop.
Use of Getopt::Long after reading 'perldoc GetOpt::Long'
#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
use feature qw(say);
use open ':std', ':encoding(UTF-8)';
use Getopt::Long;
use Data::Dumper;
my %opt;
my @opt_desc = qw(length|l=i file|f=s verbose|v);
my $getopt = Getopt::Long::Parser->new(
config => [qw(gnu_getopt no_ignore_case)]
);
if ($getopt->getoptions(\%opt, @opt_desc )) {
say Dumper({ opt_desc => \@opt_desc, opt => \%opt, argv => \@ARGV});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment