foreach my $logFile(@logfilelist) { open my $in , '<', $logFile or die $!; print "Umstrukturieren $logFile \n"; while( my $line = <$in> ){ if( $line =~ /^Context/ ){ $line=~ s/^Context:\s+//; @array = split /\s/, $line; $line = join "|", @array; if( $array[2] ne '' ){ $counter++; if($logFile =~ /^dn/) { print $frontend_context "$counter|$line\n"; } elsif($logFile =~ /^logfile/ || /^inoutput/) { print $backend_context "$counter|$line\n"; } } } }