blib/script/iof.pl untested

filter: Statementstmt 0.0% 0 / 45 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 15 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 84 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 BEGIN { $ENV{GONZLOG_SILENT} = 1 }
4  
5 use 5.010;
6  
7 use Bio::Gonzales::Project::Functions;
8 use Bio::Gonzales::Util::Cerial;
9 use Pod::Usage;
10 use String::ShellQuote;
11 use Getopt::Long qw(:config auto_help);
12  
13 my %opt = ( quote => 1, sep => ' ' );
14 GetOptions( \%opt, 'sep|s=s', 'flat|flatten|f', 'quote|q!', 'json|j' ) or pod2usage(2);
15  
16 gonzlog->tee_stderr(0);
17 gonzlog->namespace("gonzconf");
18 my @args = @ARGV;
19 my $res = gonzconf shift @args;
20 for my $a (@args) {
21 if ( ref $res eq 'ARRAY' && $a =~ /^\d+$/ && scalar @$res > $a) {
22 $res = $res->[$a];
23 } elsif ( ref $res eq 'HASH' ) {
24 $res = $res->{$a};
25 } else {
26 die "could not access the structure: $a";
27 }
28 }
29  
30 if ( $opt{json} ) {
31 print jfreeze $res;
32 } elsif ( $opt{flat} && ref $res eq 'ARRAY' ) {
33 my $args;
34 if ( $opt{quote} ) {
35 $args = shell_quote(@$res);
36 } else {
37 $args = join $opt{sep}, @$res;
38 }
39 print $args;
40 } elsif ( $opt{flat} && ref $res eq 'HASH' ) {
41 my $args;
42 if ( $opt{quote} ) {
43 $args = shell_quote( keys %$res );
44 } else {
45 $args = join $opt{sep}, keys %$res;
46 }
47 print $args;
48 } elsif ( ref $res ) {
49 print jfreeze $res;
50 } else {
51 chomp $res;
52 print $res;
53 }