in reply to &process or die

I'm astonished that you say your subroutine works properly without the die, because it shouldn't.

Your subroutine should start with

sub process{ my $outfile= shift;