you’re missing parens on open when you create your output file so it’s not parsing the way you intend
This isn't wrong but equally the parens are not needed if or is used for control flow instead of ||. All three of these work (my preference in the comments)
open( my $out_fh, q{>}, $outfile ) || die qq{problem writing to '$outf
+ile': $!}; # OK
open( my $out_fh, q{>}, $outfile ) or die qq{problem writing to '$outf
+ile': $!}; # Better
open my $out_fh, q{>}, $outfile or die qq{problem writing to '$outfile
+': $!}; # Best
The last of these is an idiom I use all the time (albeit with actual quotation marks rather than q/qq). I find that absence of unnecessary punctuation makes for clearer reading but recognise that not everyone sees it the same way. There is also autodie if you don't want or need to write your own error messages.
All the rest of Fletch's advice is spot on. I'd also point you (joluito) to the Basic debugging checklist for help in finding out where things are going wrong.