MegaDistro/ParseList.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 65 CC 9 SCAR 40.7
CC
9
Cov
0%
get_modlist
90.0
BEGIN
2.0
BEGIN
2.0
CRAP 58.6
1 package MegaDistro::ParseList;
2  
3 use strict;
4 use warnings;
5  
6 use Exporter;
7 our @ISA = qw(Exporter);
8 our @EXPORT_OK = qw(get_modlist);
9  
10 use lib './MegaDistro';
11  
12 use MegaDistro::Config;
13  
14  
15 sub get_modlist {
16 my $modlist = $Conf{'modlist'};
17  
18 if ( $args{'trace'} ) {
19 print 'MegaDistro::ParseList : Executing sub-routine: get_modlist' . "\n";
20 }
21
22 if ( $modlist ) {
23 if ( ! -e "$modlist" ) {
24 die "\n" . "Module list " . $modlist . " does not exist!" . "\n";
25 }
26 elsif ( ! -s "$modlist" ) {
27 die "\n" . "Module list " . $modlist . " is empty!" . "\n";
28 }
29 }
30 open( MODLIST, "<$modlist" ) || die "Cannot open $modlist: $!";
31 my @FILE = <MODLIST>;
32 close( MODLIST );
33 my @modlist;
34 for (@FILE) {
35 my $line = $_;
36 chomp($line);
37 next if $line=~ /^\#/;
38 next if $line=~ /^\s*$/;
39 push @modlist, $line;
40 }
41 if ( ! scalar @modlist ) {
42 die "\n" . "Module list empty -- nothing to do." . "\n";
43 }
44 else {
45 if ( $args{'debug'} ) {
46 print "\t" . 'Successfully read in module list - Contains: ' . scalar @modlist . ' modules' . "\n";
47 }
48 }
49  
50 return @modlist;
51 }
52  
53 1;