#!/usr/bin/perl use strict; use warnings; open( my $file, "/tmp/bighurkinfile" ) or die "failed to open bighurkinfile: $!"; chomp( my $pattern = <$file> ); # assumes pattern on first line by itself my @records; { local $/ = undef; @records = split /$pattern/, <$file>; # probably should do sanity check on the pattern first... }