Absolute path problem

S

seema

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
 
P

phaylon

seema said:
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
 
B

Brian McCauley

seema said:
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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top