Thread Letzte 10 Zeilen einer Textdatei ausgeben (73 answers)
Opened by TrioxX at 2006-12-03 12:20

renee
 2006-12-06 14:21
#9293 #9293
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code: (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
#!/usr/bin/perl

use strict;
use warnings;

my @lines = <DATA>;
my @result;

my %hash = (leaved => ' verlaesst den Raum',
entered => ' betritt den Raum');

for my $line(@lines){
chomp $line;
my ($time,$action,$nick,$text) = (split /\|/,$line)[0,3,4,7];
my $nice = localtime($time);
unless($action eq 'text'){
$text = $nick . $hash{$action};
}
push @result, '('.$nice.') '.$text
}

print $_,"\n" for @result;

__DATA__
1165404989||lobby|entered|christian|Christian|lobby
1165404989||lobby|leaved|christian|Christian|lobby
1165403782||lobby|text|christian|Christian|#404040|xxx
1165403706||lobby|entered|christian|Christian|lobby
1165403706||lobby|leaved|christian|Christian|lobby
1165402923||lobby|entered|christian|Christian|lobby
1165402923||lobby|leaved|christian|Christian|lobby
1165402716||lobby|entered|christian|Christian|lobby
1165402595||lobby|leaved|christian|Christian|lobby
1165402433||lobby|entered|christian|Christian|lobby
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Letzte 10 Zeilen einer Textdatei ausgeben