Once I encountered a problem concerning an exported peagasus mailfile. It was several hundreds of megabytes big. My oportunity was to split it into parts, each containing exactly one mail. As the file had a nice seperator, it seemed quite easy to me - but the first attempt blew up my memory. This was the first time I came to use the $_ variable instead of an own:
open(FH,"<$source") || die "cant open $source: $!\n";
while (<FH>){
push @file, $_;
if ($_ =~ /^-- End --/) {
$zaehler++;
open(GUN,">$destiny") || die "can write to $destinyfile$zaehle
+r:$!";
foreach $zeile (@file) {
print GUN $zeile;
}#endforeach
undef @file;
close(GUN);
print "$zaehler:\n";
}#endif
}#endwhile
close(FH);