I need to check whether a file in a user\'s home directory exists so use file check:
if ( -e \"~/foo.txt\" ) { print \"yes, it exists!\" ; }
Try File::Path::Expand.