public
Created

  • Download Gist
opt.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
 
my @c = ();
my @m = ();
GetOptions('c=s' => \@c, 'm=s' => \@m);
my $argument = shift @ARGV;
die "a mandatory parameter `argument'" unless $argument;
 
use Data::Dumper; print Dumper {'c' => \@c, 'm' => \@m, 'argument' => $argument};
$ perl opt.pl -c name1 -c name2 -m name3 argument
$VAR1 = {
          'argument' => 'argument',
          'c' => [
                   'name1',
                   'name2'
                 ],
          'm' => [
                   'name3'
                 ]
        };

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.