#!/usr/bin/perl use strict; use warnings; my @Buffer = (); my $i = 0; while(my $line = ){  $Buffer[$i] .= $line;  $i++ if($line =~ /"\$("\s")+"$/);  if($i == 20){ print2File(\@Buffer); $i = 0;   @Buffer = (); } } sub print2File{ my ($buffer) = @_; foreach my $set(@{$buffer}){  my (undef,$name,undef) = split(/\n/,$set,3);  ($name) = $name =~ /"([^"]+)/;  $name =~ s/\s/_/g;  open(W_FILE,">$name") or die $!;  print W_FILE $set;  close W_FILE; } } "beginn erster Datensatz" "" "" "matthew01" "" "" "texttexttexttetx text text" "" "" "texttext text" "" "98387" "text, text" "" "" "text" "" "" "" "" "" "text" 0.00 0.00 "$" "" "" "" "" "" "matthew02" "" "" "" "" "" "texttext text" "5330146514" "" "" "" "" "text, text" "" "" "" "" "" "text" "30.06.1999" "" "$" "" "" "" "" "" "matthew03" "" "" "" "" "" "texttext text" "5330146514" "" "" "" "" "text, text" "" "" "" "" "" "text" "30.08.2000" "" "$" "" "" "" "" "" "matthew04" "" "" "" "" "" "texttext text" "5330146514" "" "" "" "" "text, text" "" "" "" "" "" "text" "30.08.2000" "" "$" "" """ "" "text, text" "" "" "" "" "" "text" "30.08.2000" "" "$" "" """ ""