blib/lib/MYDan/Collector/Stat/Watch.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 43 CC 4 SCAR 23.0
CC
4
Cov
0%
co
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 10.0
1 package MYDan::Collector::Stat::Watch;
2  
3 use strict;
4 use warnings;
5 use Carp;
6 use POSIX;
7  
8 use MYDan::Collector::Util;
9  
10 sub co
11 {
12 my ( $this, @watch, @stat, %watch ) = @_;
13  
14 push @stat, [ 'WATCH', 'current', 'type' ];
15  
16 map{ $watch{$1} = 1 if $_ =~ /^\{WATCH\}\{([^}]+)\}\{\w+\}/ }@watch;
17  
18 for my $watch ( keys %watch )
19 {
20 my @data = ( $watch );
21  
22 if( -l $watch )
23 {
24 push @data, readlink $watch, 'link';
25 }
26 elsif( -f $watch )
27 {
28 my $cont = MYDan::Collector::Util::qx( "cat '$watch'" ); chomp $cont;
29 push @data, $cont, 'cont';
30 }
31 else
32 {
33 push @data, '', 'unkown';
34 }
35  
36 push @stat, \@data;
37 }
38  
39 return \@stat;
40 }
41  
42 1;