in reply to Re: How to convert unix ~path (tilde) to full path
in thread How to convert unix ~path (tilde) to full path
Zaxo speaks the truth... Adapted from The Perl Cookbook (pg.231)...
my $file = '~rich36/perl/makeperl'; $file =~ s{ ^ ~ ( [^/]* ) } { $1 ? (getpwnam($1))[7] : ( $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($>))[7] ) }ex; print "$file"; __DATA__ /home/users/rich36/perl/makeperl
|
|---|