#!perl use strict; use warnings; open my $fh_big_file, '<', $ARGV[0] || die; #first argument must be the input file open my $fh_regex, '<', $ARGV[1] || die; # second argument points to the file containing the regex my $regex = <$fh_regex>; while(<$fh_big_file>) { print if (/$regex/../^END_OF_BLOCK/); }