Failed to parse command line options

#!/usr/bin/perl -sw
use strict;
use warnings;
use Getopt::Long;

my $remote = 0;
my $test = 0;
GetOptions ('remote' => \$remote, 'test' => \$test);
print "$remote:$test\n";

perl test.pl --remote --test

The above columns are "0: 0". I am new to Perl, so I have not been able to determine why this is not working.

I also launched the "Simple Options" section from http://perldoc.perl.org/Getopt/Long.html#Simple-options and did nothing.

+5
source share
1 answer

I believe that the command line option -sthat you include in your line is biting you. According to the perlrun documentation , the command line parameter is -s:

, ( -).

, , . -w, use warnings ( use warnings , -w).

, , :

#!/usr/bin/perl
+11

All Articles