in reply to suppress warning: Exiting subroutine via next
next unless m/.txt$/i;
with
return unless m/.txt$/i;