-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathperlcheat.pl
More file actions
executable file
·39 lines (31 loc) · 1.07 KB
/
perlcheat.pl
File metadata and controls
executable file
·39 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env perl
use Getopt::Long;
use File::Basename;
my $USAGE = "Usage ". basename $0 ." [ -b ] -a OPTIONA FILE [ FILE... ]";
## Hey, this might be a cool way to test
# TEST ; fails with 255 and STDERR matches /^Usage/
# TEST -b ; fails with 255 and STDERR matches /^Usage/
# TEST -a ; fails with 255 and STDERR matches /^Usage/
# TEST -a optiona ; succeeds and STDOUT matches /^OPTIONA optiona/
# TEST -b -a optiona ; succeeds and STDOUT matches /^OPTIONA optiona/ and STDOUT matches /^OPTIONB 1/
# TEST -a optiona filea fileb filec ; succeeds and STDOUT matches /^OPTIONA optiona/
# TEST -b -a optiona ; succeeds and STDOUT matches /^OPTIONA optiona/ and STDOUT matches /^OPTIONB 1/
my $optiona = '';
my $optionb = 0;
my $options = GetOptions(
"a=s" =>\$optiona,
"b!" =>\$optionb,
);
# TODO - Invalid options -c, etc?
# TEST -c ; fails with -1 and STDERR matches /^Usage/
#require option -a
if ($optiona eq '') {
print STDERR $USAGE . "\n";
exit -1;
}
print "OPTIONA $optiona\n";
print "OPTIONB $optionb\n";
my @files = @ARGV;
for my $file (@files) {
print "FILE: $file\n";
}