7.3. Expanding Tildes in FilenamesProblem
You want to open filenames like
~username/blah
, but SolutionExpand the filename manually with a substitution: $filename =~ s{ ^ ~ ( [^/]* ) } { $1 ? (getpwnam($1))[7] : ( $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($>))[7] ) }ex; DiscussionThe uses of tilde that we want to catch are: ~user ~user/blah ~ ~/blah
If no name follows the
This substitution uses See Also
Your system's
getpwnam
(2) manpage; the |
|