#!/usr/local/bin/perl -w use strict; 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; #------------------------------------------------------------------------------------------------------------------------------------------------------------------------ open(IN,$dumpfile) || die "Fehler beim Öffnen von $dumpfile: $!\n"; print "Error_Type\tCount\n"; while (){ chomp($_); if(/([\[]\d+[\]])/){ # find an error number in the input file. format: [0-310] my $number="$1"; $error{$number} += 1; } } close(IN); foreach my $key (sort keys %error){ print $key."\t"."\t".$error{$key}."\n" } #-------------------------------------------------------------------------- if (! -d $resdir) { mkdir($resdir) || die("Could not create result directory $resdir\n"); } foreach my $key (sort keys %error){ open(IN,$dumpfile) || die "Fehler beim Öffnen von $dumpfile: $!\n"; open(OUT, ">$resdir/${dumpfile}_$key.txt"); while (){ chomp($_); if(/.*[$key]/){ printf OUT ("$_\n"); } } close (OUT); close (IN); }