my @mailfiles = ; foreach my $file (@mailfiles){ my @text_blocks; open TEXT, '<', $file or die "could not open $file"; my $text; while (){ $text .= $_; } @text_blocks = split(/\n{2,}/, $text); close TEXT; #also tried the method below with similar results #{ # local $/ = ''; # @text_blocks = ; #} #close TEXT; print scalar(@text_blocks); }