File Coverage

blib/lib/Mnet/Dump.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 21 22 95.4


line stmt bran cond sub pod time code
1             package Mnet::Dump;
2              
3             # purpose: functions to Data::Dumper used internally by other Mnet modules
4              
5             # required modules
6 1     1   8 use warnings;
  1         2  
  1         34  
7 1     1   6 use strict;
  1         2  
  1         18  
8 1     1   653 use Data::Dumper;
  1         6944  
  1         161  
9              
10              
11              
12             sub line {
13              
14             # $line = Mnet::Dump::line($value)
15             # purpose: returns single line sorted Data::Dumper output for input value
16             # $value: input variable to dump, can be a scalar, hash, array, reference, etc
17             # $line: output Data::Dumper line, examples: undef, "value", [ list ], { etc }
18              
19             # read input value, dump it as a sorted single Data::Dumper line
20 6     6 0 13 my $value = shift;
21 6         26 my $value_dumper = Data::Dumper->new([$value]);
22 6         187 $value_dumper->Indent(0);
23 6         79 $value_dumper->Sortkeys(1);
24 6         39 $value_dumper->Useqq(1);
25 6         70 my $value_dump = $value_dumper->Dump;
26 6         132 $value_dump =~ s/(^\$VAR1 = |;\n*$)//g;
27 6         56 return $value_dump;
28             }
29              
30              
31             # normal end of package
32             1;
33