Update: changed 'if ($#ARGV % 2 == 0)' to 'if ($#ARGV <= 2 || $#ARGV >= 4)'use strict; use warnings; use v5.16; my $infile; my $outfile; if ($#ARGV <= 2 || $#ARGV >= 4){ die "Silly you, there are an incorrect amount of args :)\n" } for ( 0 .. $#ARGV / 2 ) { my $switch = shift(@ARGV); my $value = shift(@ARGV); given ($switch) { when ('-f1') { $infile = $value } when ('-f2') { $outfile = $value } } } print "Infile: $infile\n", "Outfile: $outfile";
In reply to Re: GetOpts not working:
by james28909
in thread GetOpts not working:
by finfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |