#!/usr/local/bin/perl -w use strict; use warnings; my $dumpfile = "Proba.txt"; # write the name of the input file my $resdir = "errors"; # directory where will be saved the files # with the different error records my %error; #------------------------------------------------------------------------------# if (! -d $resdir) { mkdir($resdir) or die("Could not create result directory $resdir\n"); } open (my $in, '<', $dumpfile) or die "Fehler beim Öffnen von $dumpfile: $!\n"; while (my $line = <$in>) { if ( $line =~ m|(\[\d+\])| ) { push @{$error{$1}}, $line; # Trefferzeile sofort im %error-Hash ablegen } } close $in; print "Error_Type\tCount\n"; for my $key (sort keys %error) { print "$key\t" . scalar @{$error{$key}} . "\n"; # Anzahl open(my $out, '>', "$resdir/${dumpfile}_$key.txt") or die $!; print $out join('', @{$error{$key}}); close $out; }