script/pronom_statistics.pl untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 5 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 75 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 #===============================================================================
3 #
4 # FILE: pronom_statistics.pl
5 #
6 # USAGE: ./pronom_statistics.pl
7 #
8 # DESCRIPTION: perl ./pronom_statistics.pl <DROIDSIGNATURE-FILE>
9 #
10 # OPTIONS: ---
11 # REQUIREMENTS: ---
12 # BUGS: ---
13 # NOTES: ---
14 # AUTHOR: Andreas Romeyke,
15 # CREATED: 28.08.2018 14:26:43
16 # REVISION: ---
17 #===============================================================================
18 # PODNAME: pronom_statistics.pl
19 use strict;
20 use warnings 'FATAL';
21 use utf8;
22 use feature qw(say);
23 use Carp;
24 use Getopt::Long;
25 use Term::ProgressBar;
26 use File::FormatIdentification::Pronom;
27  
28 ################################################################################
29 # main
30 ################################################################################
31 my $csv_file;
32 my $verbose;
33 my $progress_flag = 1;
34 GetOptions (
35 "csvfile=s" => \$csv_file,
36 "verbose" => \$verbose,
37 "progress!" => \$progress_flag,
38 "help" => sub {
39 say "$0 [--csvfile=FILE] [--verbose] [--noprogress] droid_signature_filename1 [.. droid_signature_filenameN]";
40 say "$0 --help ";
41 say "";
42 say "--csvfile=FILE .............. creates a CSV file to store statistics";
43 say "--verbose ................... enables more verbose output in standard report";
44 say "--noprogress ................ disables progress bar";
45 say "droid_signature_filename..... DROID signature files (container files not supported yet)";
46 }
47 ) or croak "wrong option, try '$0 --help'";
48 if ((defined $csv_file) && (-e $csv_file)) {
49 croak "CSV file '$csv_file' already exist";
50 }
51 say "using ",scalar @ARGV," signature files";
52 my $progress = Term::ProgressBar->new( $#ARGV );
53 for (my $idx=0; $idx <= $#ARGV; $idx++) {
54 my $pronomfile = $ARGV[$idx];
55 if ( !defined $pronomfile ) {
56 say "you need at least a pronom signature file";
57 }
58 my $pronom = File::FormatIdentification::Pronom->new(
59 "droid_signature_filename" => $pronomfile
60 );
61 if (defined $csv_file) {
62 $pronom->print_csv_statistics( $csv_file );
63 } else {
64 $pronom->print_statistics( $verbose );
65 }
66 if ($progress_flag) {
67 $progress->update($idx);
68 }
69 }
70 1;
71  
72 __END__
73  
74 =pod
75  
76 =encoding UTF-8
77  
78 =head1 NAME
79  
80 pronom_statistics.pl
81  
82 =head1 VERSION
83  
84 version 0.06
85  
86 =head1 AUTHOR
87  
88 Andreas Romeyke <pause@andreas-romeyke.de>
89  
90 =head1 COPYRIGHT AND LICENSE
91  
92 This software is copyright (c) 2018 by Andreas Romeyke.
93  
94 This is free software; you can redistribute it and/or modify it under
95 the same terms as the Perl 5 programming language system itself.
96  
97 =cut