use strict; use warnings; opendir(DIR,"test"); while($datei = readdir(DIR)) { open(INPUT,'<',"test/$datei"); print $datei; undef $/; #open (OUTPUT,">>Ausgabe.txt") or die "konnte $ziel nicht oeffnen,$!\n"; $_ = ; tr/\000//d; s/" /"\n/g; s/>/>\n/g; #print "$_\n"; (my $testschritt) = $_ =~ /SNNH-UB01-002/gsm; print "$testschritt\n"; if(defined($testschritt)) { #print "$datei\n"; #rename("test/$datei", "SNNHUB01/$datei"); #print "$testschritt\n"; #chmod 0777, $datei; #unlink ('test/$datei'); system "copy \"test\$datei\" SNNHUB01\\"; } close (INPUT); close(FILE); } closedir(DIR);