Thread Regülarer Ausdrück zu einem hash array (19 answers)
Opened by Tom99 at 2008-10-04 15:42

Tom99
 2008-10-04 16:25
#115157 #115157
User since
2008-10-04
10 Artikel
BenutzerIn
[default_avatar]
Mein kommpleter Script sah so aus
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/perl -w
use Data::Dumper;

use switch;
my $file = "C:/Programme/UrbanTerror/q3ut4/games.log";

open ( FILE, $file ) or die ("Cannt open File $file");

while (defined(my $line = <FILE>))
{
        if ($line =~ /^\s+(\d{1,2}:\d{2}) ((\w+):(?: )?(.*)?)/)
                {
                my $time = $1;
                        if (defined ($3))
                        {
                                if (defined ($4))
                                {
                                        if ($3 eq "ClientConnect")
                                        {
                                                &ClientConnect($4);
                                        }
                                        if ($3 eq "ClientBegin")
                                        {
                                                &ClientBegin($4);
                                        }
                                        if ($3 eq "ClientUserinfo")
                                        {
                                                &ClientUserinfo($4);
                                        }
                                }
                        }
                }
}

sub ClientConnect {
        local $id = shift;
#       print ("Client $id connected\n");
        return 1;
}
sub ClientBegin {
        local $id = shift;
#       print ("Client $id began\n");
        return 1;
}
sub ClientUserinfo {
        local $line = shift;
        if ($line =~ /(\d+) \\(.*)/)
        {
        #print "Client $1: $2\n";
        # HIER SOLL
        local $logline = $2;
        local @array = ($logline =~ /([^\\]+)\\([^\\]+)/g);
        local %playerinfo;
        for ($i = 0; $i <= @array; $i += 2)
                {
                $playerinfo{$array[$i]} = $array[$i+1];
                }
        print Dumper  \%playerinfo;
#       %playerinfo = $logline =~ m! /([^/]+)/([^/]+)/ !xg;
#       print Dumper  \%playerinfo;
        die();
        }
        return 1;
}

View full thread Regülarer Ausdrück zu einem hash array