Thread Daten aus einer Log File zählen
(2 answers)
Opened by Gast at 2007-07-30 17:01 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 #!/usr/bin/perl use strict; use warnings; my $file = 'logdatei.txt'; my %hash; { # wenn die Datensaetze durch leerzeile getrennt sind local $/ = "\n\n"; open my $fh, '<', $file or die $!; while( my $entry = <$fh> ){ my ($date) = $entry =~ /(\d{4}-\d\d-\d\d)/; next unless $date; $hash{$date}++; } close $fh; } for my $key ( keys %hash ){ print "$key: ",$hash{$key},"\n"; } 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/ |