use strict; use warnings; my $file = '782426.pl'; open(my $fh, '<', $file) or die "$file: $!"; my @records = do { local $/ = "\032"; <$fh> }; close($fh); # Discard first and last records shift(@records); pop(@records); foreach (@records) { chop; # remove trailing \032 (record separator) s/^[^\.]*\.+\s*//gm; # Do what you want with the record here print "\n****\n$_\n"; }