mmartin has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use warnings; use strict; use File::Copy; use Getopt::Long; use Term::ANSIColor qw(:constants); $Term::ANSIColor::AUTORESET = 1; # TEST --> Print the Args so we can see that they are being passed: print "\@ARGV: \"@ARGV\"\n\n"; my $srv_address; my $ip_address; if ( @ARGV > 0 ) { print "GETTING OPTIONS...\n\n"; GetOptions('ipAddr=s' => \$ip_address, 'server=s' => \$srv_address ); } print BOLD " IP Address = " . RESET "$ip_address\n"; print BOLD "SERVER Address = " . RESET "$srv_address\n"; exit 0;
@ARGV: "ipAddr=192.168.5.196 server=192.168.5.1" GETTING OPTIONS... Use of uninitialized value $ip_address in concatenation (.) or string +at ./test_diff.pl line 25. IP Address = Use of uninitialized value $srv_address in concatenation (.) or string + at ./test_diff.pl line 26. SRV Address =
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GetOptions Function NOT Assign CLI Args to Variables?
by frozenwithjoy (Priest) on Oct 12, 2012 at 18:08 UTC | |
|
Re: GetOptions Function NOT Assign CLI Args to Variables?
by toolic (Bishop) on Oct 12, 2012 at 18:40 UTC | |
|
Re: GetOptions Function NOT Assign CLI Args to Variables?
by mmartin (Monk) on Oct 12, 2012 at 18:55 UTC |