Thread Array-Lines zählen (12 answers)
Opened by cohama at 2014-05-06 15:09

payx
 2014-05-06 15:22
#175331 #175331
User since
2006-05-04
564 Artikel
BenutzerIn

user image
Hallo cohama,

Code (perl): (dl )
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
#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my @data; # Das Array, das Du schon erzeugst
my %id_count; # Hash: zu jeder ID (die Zahlen am Zeilenanfang) die Anzahl der Vorkommen

while (my $row = <DATA>) {
    
    chomp $row;
    
    push @data, $row;
    
    my ($id) = ($row =~ /^(\d+)/);
    
    $id_count{$id}++;

}

print Dumper \%id_count;

__DATA__
3681     OUT 2014-05-06 12:57:05 22     30     3338359406   3338753402   unkown           8414        
3681     OUT 2014-05-06 12:39:44 37     43     3338359406   3338753402   unkown           8414        
3681     OUT 2014-05-06 11:56:15 191    210    3338359406   3338753402   unkown           3991110     
3681     OUT 2014-05-06 12:06:15 0      10     3338359406   3338753402   unkown           033372270   
5494     OUT 2014-05-06 06:25:48 149    172    3375550834   X            international    0038763931307
5494     OUT 2014-05-06 07:43:49 419    443    3375585134   X            international    0038763649266
5494     OUT 2014-05-06 11:41:07 127    141    3375585134   X            international    002207733514
5494     OUT 2014-05-06 08:54:48 252    259    3375550834   X            international    00447589972757
5494     OUT 2014-05-06 01:28:17 0      11     3375585133   X            international    0023221350752
5494     OUT 2014-05-06 11:41:15 121    133    3375550834   X            international    0022062892015
5494     OUT 2014-05-06 01:28:25 0      10     3375585133   X            international    005331997555
5494     OUT 2014-05-06 01:28:39 0      12     3375585133   X            international    002392204144
5494     OUT 2014-05-06 08:15:03 0      14     3375585133   X            international    0038763456569
5494     OUT 2014-05-06 08:15:02 0      14     3375585134   X            international    0038763649266
5494     OUT 2014-05-06 11:41:09 122    131    3375585133   X            international    0022062892015
5494     OUT 2014-05-06 08:14:36 0      14     3375585134   X            international    0038763649266
5494     OUT 2014-05-06 01:29:00 0      10     3375585133   X            international    0037125050148
7787     OUT 2014-05-06 04:06:37 125    132    3376290890   X            international    00447589972819
7787     OUT 2014-05-06 04:06:51 124    131    3376290890   X            international    00447589972819
7787     OUT 2014-05-06 04:06:58 127    134    3376290890   X            international    00447589972819
7787     OUT 2014-05-06 07:24:22 121    128    3376290890   X            international    00447589972819
7787     OUT 2014-05-06 08:44:07 126    133    3376290890   X            international    00447589972819
7787     OUT 2014-05-06 04:07:26 119    126    3376290890   X            international    00447589972819
7787     OUT 2014-05-06 04:07:40 122    129    3376290890   X            international    00447589972819
7787     OUT 2014-05-06 10:48:55 127    146    3376290890   X            international    002207396071


HTH
Grüße
payx

View full thread Array-Lines zählen