sub process_file { ... if (-f $dummy) { ... open(my $fh, ... ... } close $fh; }