use strict; use warnings; my $forbpjoutput = q(); open my $bpfh1, '<', \$forbpjoutput or die $!; ... # Exactly as in your post.