in reply to how to expand home directory ~

Those 2 paths are not the same:

Maybe you made a typo and you meant ~madam not ~/madam - in which case they should be the same...


s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&

Replies are listed 'Best First'.
Re^2: how to expand home directory ~
by muntfish (Chaplain) on Jun 02, 2005 at 12:31 UTC

    Of course my previous post may be irrelevant, as Joost points out, Perl doesn't expand ~ anyway...

    There are a few different ways to expand ~, if you need to:

    • Globbing - either <~madam> or glob('~madam') should both work, or you can look at File::Glob.
    • Regexp to replace ~ with $ENV{HOME} assuming $HOME is set (it almost always is) on your Unix environment. That only works if you're interested in the current user's home dir of course.
    • Some other module may do it - File::Spec doesn't but there are heaps of other modules under File:: on CPAN!

    Hope that helps!


    s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&