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
    1. Advertising

  2. seema

    phaylon Guest

    seema wrote:

    > I have tried glob() it only resolves string when used as command.


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

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

    hth,p

    --
    http://www.dunkelheit.at/
    sapere aude.
     
    phaylon, Mar 22, 2005
    #2
    1. Advertising

  3. seema wrote:

    > I am fresher learning perl programming.


    So it is quite likely that most questions you have will be one that are
    frequently asked.

    > 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.


    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
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    3
    Views:
    19,577
    Sudsy
    Jul 8, 2004
  2. Replies:
    10
    Views:
    3,600
  3. Thomas Guettler
    Replies:
    3
    Views:
    765
    Andrei
    Oct 27, 2003
  4. Nigel Wilkinson
    Replies:
    2
    Views:
    390
    Nigel Wilkinson
    Jul 25, 2005
  5. James Byrne
    Replies:
    3
    Views:
    569
    James Byrne
    Sep 14, 2010
Loading...

Share This Page