Absolute path problem

Discussion in 'Perl Misc' started by seema, Mar 22, 2005.

  1. seema

    seema Guest

    hi all,
    I am fresher learning perl programming. Is it possible
    to resolve the (.,~) to give the absolute path. for
    example to parse strings like "~john" or "../john/LFS"
    to get the absolute path of directory specified. I have tried glob() it only
    resolves string when used as command. Somebody please
    help me to get the absolute path.

    thanks in advance
    Seema Rao
    seema, Mar 22, 2005
    1. Advertisements

  2. seema

    phaylon Guest

    Please read the posting guidelines and give an example of what you've

    phaylon@hamlett:~> perl -e "print 'Homedir: ', glob('~')"
    Homedir: /home/phaylon

    phaylon, Mar 22, 2005
    1. Advertisements

  3. So it is quite likely that most questions you have will be one that are
    frequently asked.
    Those are two separate questions. ~ and .. are conceptually very
    different - one is part of the shell and the other part of the filesystem.

    Both questions are frequently asked and one is even Frequently Asked.

    The answer to one is Cwd::abspath but that you probably really should
    not do it - it is usually detremental to convert a relative path to an
    absolute one. See numerous previous threads for details.

    The answer to the other question is in the FAQ.
    Brian McCauley, Mar 23, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.