sub process { return if -d $_; # ... then the rest of your function