line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Linux::net::dev; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.000; |
4
|
1
|
|
|
1
|
|
789
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
104
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
1
|
|
|
1
|
|
919
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
1718
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
14
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
15
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# This allows declaration use Linux::net::dev ':all'; |
18
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
19
|
|
|
|
|
|
|
# will save memory. |
20
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
) ] ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our @EXPORT = qw( |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Preloaded methods go here. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub info { |
34
|
1
|
50
|
|
1
|
1
|
123
|
return {} unless -r "/proc/net/dev"; |
35
|
1
|
|
|
|
|
35
|
open(DEV, "/proc/net/dev"); |
36
|
1
|
|
|
|
|
3
|
my (@titles, %result); |
37
|
1
|
|
|
|
|
43
|
while (my $line = ) { |
38
|
4
|
|
|
|
|
6
|
chomp($line); |
39
|
4
|
100
|
|
|
|
26
|
if ($line =~ /^.{6}\|([^\\]+)\|([^\\]+)$/) { |
|
|
50
|
|
|
|
|
|
40
|
2
|
|
|
|
|
8
|
my ($rec, $trans) = ($1, $2); |
41
|
10
|
|
|
|
|
18
|
@titles = ( |
42
|
10
|
|
|
|
|
25
|
(map { "r$_" } split(/\s+/, $rec)), |
43
|
2
|
|
|
|
|
8
|
(map { "t$_" } split(/\s+/, $trans)), |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} elsif ($line =~ /^\s*([^:]+):\s*(.*)$/) { |
46
|
2
|
|
|
|
|
15
|
my ($id, @data) = ($1, split(/\s+/, $2)); |
47
|
32
|
|
|
|
|
82
|
$result{$id} = { map { |
48
|
2
|
|
|
|
|
7
|
$titles[$_] => $data[$_]; |
49
|
|
|
|
|
|
|
} (0..$#titles) }; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
1
|
|
|
|
|
10
|
close(DEV); |
53
|
1
|
|
|
|
|
5
|
return \%result; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub dev { |
57
|
0
|
0
|
|
0
|
1
|
|
croak "Missing parameter" unless @_; |
58
|
0
|
|
|
|
|
|
return info()->{$_[0]}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub devs { |
62
|
0
|
0
|
|
0
|
1
|
|
croak "Missing parameters" unless @_; |
63
|
0
|
|
|
|
|
|
return @{info()}{@_}; |
|
0
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |