open(FILE, "$lfilename") or &dienice; $/ = undef; # Slurp mode $file = (); # Grab the whole file into $file while (my($record) =~ m/Begin Product(.*?)End Product/gs) { print $record; }