#!/usr/bin/perl -w use strict; $/ = qq{"\$"\t""\t""\n}; my $inputfile = 'export_gesamt.asc'; open A, $inputfile or die "Cannot open '$inputfile': $!"; while ( ) { my $file = ( split /\n/, $_ )[1] or next; ( $file ) = $file =~ m/"(.*?)"/ or next; open B, "> $file.csv" or warn( "Cannot open '$file': $!" ), next; print "[DEBUG] '$file': open ok\n"; chomp $_; print B $_; close B or warn( "Cannot close '$file': $!" ), next; print "[DEBUG] '$file': close ok\n"; } __END__