script/listpdffields2.pl untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 69 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl -w
2  
3 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
4 if 0; # not running under some shell
5  
6 package main;
7  
8 use warnings;
9 use strict;
10 use CAM::PDFTaxforms;
11 use Getopt::Long;
12 use Pod::Usage;
13  
14 our $VERSION = '1.00';
15  
16 my %opts = (
17 sort => 0,
18 verbose => 0,
19 data => 0, #JWT:ADDED 20100921 TO DISPLAY FIELD VALUES ALSO.
20 help => 0,
21 version => 0,
22 );
23  
24 Getopt::Long::Configure('bundling');
25 GetOptions('s|sort' => \$opts{sort},
26 'v|verbose' => \$opts{verbose},
27 'd|data' => \$opts{data},
28 'h|help' => \$opts{help},
29 'V|version' => \$opts{version},
30 ) or pod2usage(1);
31 pod2usage(1) if ($opts{help});
32 #{
33 # pod2usage(-exitstatus => 0, -verbose => 2);
34 #}
35 if ($opts{version})
36 {
37 print "CAM::PDFTaxforms v$CAM::PDFTaxforms::VERSION\n";
38 print "CAM::PDF v$CAM::PDF::VERSION\n";
39 exit 0;
40 }
41  
42 if (@ARGV < 1)
43 {
44 pod2usage(1);
45 }
46  
47 my $infile = shift;
48  
49 my $doc = CAM::PDFTaxforms->new($infile) || die "$CAM::PDF::errstr\n";
50  
51 my @list = $doc->getFormFieldList();
52 my $fieldHash;
53 $fieldHash = $doc->getFieldValue(@list) if ($opts{data});
54 if ($opts{'sort'})
55 {
56 @list = sort @list;
57 }
58 foreach my $name (@list)
59 {
60 print $name, (($opts{data} && defined($$fieldHash{$name})) ? "\t$$fieldHash{$name}" : ''), "\n";
61 }
62  
63  
64 __END__