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   6 use warnings;
  1         4  
  1         32  
7 1     1   5 use strict;
  1         2  
  1         29  
8 1     1   719 use Data::Dumper;
  1         7716  
  1         180  
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 16 my $value = shift;
21 6         28 my $value_dumper = Data::Dumper->new([$value]);
22 6         170 $value_dumper->Indent(0);
23 6         86 $value_dumper->Sortkeys(1);
24 6         37 $value_dumper->Useqq(1);
25 6         32 my $value_dump = $value_dumper->Dump;
26 6         135 $value_dump =~ s/(^\$VAR1 = |;\n*$)//g;
27 6         50 return $value_dump;
28             }
29              
30              
31             # normal end of package
32             1;
33