We know the file is there before the mkpath/mkdir call for creating file "10". If that -e test doesn't find it right before that call mkpath(), that narrows the amount of code you'll have to inspect.
Or, now might be a good time to learn the Perl debugger.