1 2 3
File::Path::Expand expands user directories in filenames. For the simple case it's no more complex than s{^~/}{$HOME/}, but for other cases it consults getpwent and does the right thing.