in reply to Verifying If a directory exists

m/^\w+$|^.+$/g
Considering that anything that's matched by /^\w+$/ will also be matched by /^.+$/, you might as well write /^.+$/. Having said that, the only strings that don't match are the string "\n" and any string that contains a newline that doesn't end the string itself. I don't see a reason to check for internal newlines -- they're a bitch to enter (and unlikely to happen by accident), and people usually don't put them in directory names anyway. So, I'd just chomp (you want to do that anyway), and check if the result is different from the empty string.

Also note the /g modifier. This has side-effects. I don't think they will hurt you in this particular case, but a next time, you may get bitten by such careless usage.