in reply to GetOpts not working:
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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: GetOpts not working:
by GrandFather (Saint) on Dec 09, 2015 at 17:00 UTC | |
by james28909 (Deacon) on Dec 09, 2015 at 19:51 UTC | |
|
Re^2: GetOpts not working:
by MidLifeXis (Monsignor) on Dec 09, 2015 at 16:04 UTC | |
|
Re^2: GetOpts not working:
by stevieb (Canon) on Dec 09, 2015 at 16:44 UTC | |
|
Re^2: GetOpts not working:
by james28909 (Deacon) on Dec 10, 2015 at 02:39 UTC | |
by hippo (Archbishop) on Dec 10, 2015 at 09:13 UTC | |
by james28909 (Deacon) on Dec 10, 2015 at 15:36 UTC | |
by hippo (Archbishop) on Dec 10, 2015 at 16:08 UTC | |
by james28909 (Deacon) on Dec 10, 2015 at 16:30 UTC |