Leser: 2
![]() |
|< 1 2 >| | ![]() |
20 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
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $file = 'test.txt'; my %proc = ( 'ClientConnect' => sub{ print "Client $_[0] connected\n" }, 'ClientBegin' => sub{ print "Client $_[0] began\n" }, 'ClientUserinfo' => sub{ my $line = shift; if ( $line =~ /(\d+) \\(.*)/ ) { print "Client $1: $2\n"; my $logline = $2; my %player_info = split /\\/, $logline; print Dumper \%player_info; } # if }, ); open( my $fh, '<', $file ) or die "Cannot open file '$file': $!"; while ( my $line = <$fh> ) { chomp($line); if ( $line =~ /^\s+(\d{1,2}:\d{2}) ((\w+):(?: )?(.*)?)/ ) { if ( defined $3 and defined $4 ) { $proc{$3}->($4) if exists $proc{$3}; } # if } # if } # while __END__
Tom99+2008-10-04 18:46:19--Noch eine Frage gibts in Perl kein true oder false?
1 2 3 4 5 6 7 8
my $x = 1; if ($x) {} # true $x = 0; if ($x) {} # false $x = ""; if ($x) {} # false $x = <alles ausser 0 oder leerstring>; if ($x) {} # true
![]() |
|< 1 2 >| | ![]() |
20 Einträge, 2 Seiten |