my $searchfor = shift; $/="%%%\n" open(IN, 'datafile.txt') or die "Could not open: $!\n"; while () { print if /\Q$searchfor\E/i; }