in reply to Testing the current directory with Cwd and File::Spec
If you want to save the current directory so that you may return to it later, the best way to do it is to open "." (current directory) and save the handle. Then you fchdir() to this handle in order to restore it.
There are several problems with obtaining a text representation of the current directory instead. It may be longer than the system's maximum pathname length, it may change without you noticing (someone else renames a directory that is one of the parents of the current one), and it may even in some cases not be possible to determine what it is (missing permissions?). It is also expensive because you have to walk the chain of parent directories back to the root.
But: How do you fchdir() in Perl?
-Celada
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing the current directory with Cwd and File::Spec
by radiantmatrix (Parson) on Dec 06, 2005 at 00:04 UTC | |
by xdg (Monsignor) on Dec 06, 2005 at 00:32 UTC | |
by Celada (Monk) on Dec 06, 2005 at 05:45 UTC |