in reply to removing the need for tmp files from script

Assuming I understand what you're trying to do, it seems to me this would be easier:
for (@bpout) { print "$_\n" if /$pattern/; }