in reply to Re^2: How do I change directory to root directory
in thread How do I change directory to root directory

Correct. As long as the directory you run the script from has home as a directory underneath it.

As a side note, use full paths unless there is a very good reason not to. It makes your life much easier.

  • Comment on Re^3: How do I change directory to root directory

Replies are listed 'Best First'.
Re^4: How do I change directory to root directory
by kdelph (Initiate) on Mar 04, 2005 at 17:49 UTC
    It does not work I tried it and keep getting a message
    No such file or directory Maybe I have my syntax wrong?:

    my $file ="/opt/directoryname/directoryname/directoryname/sever/default/log/log.2005.03.04";
      Are you trying to open file? If so what is the error message you are getting when you try to open it?
        Yes I'm trying to open the file and I get a message file/direcory not found.
        When I put in a test file that is in the same directory however it is being opened. It's just not opening the file from a different directory even when I put in the full path.
Re^4: How do I change directory to root directory
by kdelph (Initiate) on Mar 04, 2005 at 19:02 UTC
    But my directory that I'm in does not have Home underneath it, it has nothing underneath it. That's my problem I'm trying to access a directory but am unable to do cd to go back to the root directory and then open the file.
      If you do this
      my $file = "/full/path/to/file.txt"; open(FILE, "<", $file) or die "Whoops: $!"; do stuff close(FILE);
      and /full/path/to/file.txt exists, you have r to the file and x to each directory in the path than it will work.

      If it does not work then there is a permissions issue most likely. (or the file doesn't exist) either way the die will tell you what failed.

      It works now thank you