#!/usr/bin/perl use warnings; use strict; my $i = 0; open IN, 'alt.txt' or die "ERROR!\n"; open OUT, '> neu.txt' or die "ERROR!\n"; open OUT2, '> neu2.txt' or die "ERROR!\n"; while () { if (m/Tech Univ Dresden/){ print OUT; } else{ print OUT2; } } close IN;