in reply to Re: How to convert unix ~path (tilde) to full path
in thread How to convert unix ~path (tilde) to full path

Unfortunately, that only works for ~/path. The ~ form also works as ~user2, meaning the home directory of user2, not the current user's home directory.

Something more complete might look like this: Warning: untested code

my $filename = "~user2/tmp"; if( $filename =~ m@^\~([^/])+@){ my $home = (getpwnam($1))[7]; if( $home){ $filename =~ s@^\~[^/]+@$home@; } }else{ $filename =~ s@^\~@$ENV{'HOME'}@; }

This should handle both cases.