#!/usr/bin/perl use strict; use warnings; $/ = '---this line is the separator---'; while () { $_ =~ s#$/##; # strip the separator line print "Data to process: \n$_\n"; } __DATA__ file 1 ---this line is the separator--- file 2 ---this line is the separator--- file 3 ---this line is the separator--- file 4 ---this line is the separator--- file 5 ---this line is the separator---