|< 1 2 >| | 16 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
package SingleState;
use Moose;
has 'state' => (isa => 'Value', is => 'rw');
has 'value' => (isa => 'Value', is => 'rw');
has 'position' => (is => 'rw');
sub to_s {
my $self = shift;
return $self->state . "\t=>\t" . $self->value . "\n";
}
package Stat;
use Moose;
has 'states' => (isa => 'ArrayRef', is => 'rw');
has 'title' => (is => 'rw');
has 'position' => (is => 'rw');
sub add_state {
my $self = shift;
return unless @_;
push @{$self->{states}}, $_ for @_;
}
sub to_s {
my $self = shift;
my $o = $self->title ? "== " . $self->title . " ==\n" : '';
$o .= $_->to_s for (sort { $a->position <=> $b->position } @{$self->states});
return $o;
}
package StatSet;
use Moose;
use Data::Dumper;
has 'stats' => (isa => 'ArrayRef', is => 'rw');
sub add_stat {
my $self = shift;
return unless @_;
push @{$self->{stats}}, $_ for @_;
}
sub report {
my $self = shift;
my $s;
$s .= $_->to_s . "\n" for (sort { $a->position <=> $b->position } @{$self->stats});
return $s;
}
package main;
my $set = new StatSet;
my $stat1 = new Stat ( title => 'CPU' );
my $stat2 = new Stat ( title => 'Memory' );
my $state1 = new SingleState( state => 'Idle', value => '92', position => 1 );
my $state2 = new SingleState( state => 'User', value => '0', position => 2 );
my $state3 = new SingleState( state => 'Cached', value => '531976', position => 1 );
$stat1->add_state( $state1, $state2 );
$stat1->position(1);
$stat2->add_state( $state3 );
$stat2->position(2);
$set->add_stat($stat1);
$set->add_stat($stat2);
print $set->report;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
open(DATEI, "<./Konfigurationsdaten/20060310.DOCFIELD") || die "Datei nicht gefunden";
my @Zeilen = <DATEI>;
close(DATEI);
my %hash2;
my $old_doc = "x";
foreach (@Zeilen){
if (/(\w+)\;(\d+)\;(\d+)/){
$dokuart = $1;
$zahl1 = $2;
$zahl2 = $3;
if($dokuart!=$old_doc){
$hash2{$old_doc}=$hash; <-------- initialisierende zeile
my %hash;
}
open(DATEI, "<./Konfigurationsdaten/20060310.REPOSITORY") || die "Datei nicht gefunden";
my @Zeilen2 = <DATEI>;
close(DATEI);
foreach(@Zeilen2){
if(/^$zahl2;([^;]+)/){
$hash{$zahl}=$1;
}
}
}
$old_doc = $dokuart;
}
foreach my $ele (%hash2){
foreach my $ele2 (keys %{$ele}){
print "$ele2\n";
}
}
open(DATEI, "<./Konfigurationsdaten/20060310.DOCFIELD") || die "Datei nicht gefunden";
my @Zeilen = <DATEI>;
my $old_doc = "x";
if(/^$zahl2;([^;]+)/){
Quote
my ($dokuart,$zahl1,$zahl2) = ( split(/;/,$zeile) )[0..2];
my( $dokuart, $zahl1, $zahl2 ) = split( /;/, $zeile );
|< 1 2 >| | 16 Einträge, 2 Seiten |