in reply to Sub in a Sub & Recursion

In your latter snippet you should sub FileName have to get the value or refernce passed to it using shift or @ARGV or @_ or ....
As there is also TIMTOWDI you might want to read passing refs to subs

Have a nice day
All decision is left to your taste