What is the difference between the cd shell command and the Perl function chdir? Please can you explain with an example?
2 Answers
The cd command changes the current directory of a shell process; the Perl chdir function changes the current directory of a Perl process. They're exactly the same thing, just spelled differently.
Essentially both of them do the same thing, but chdir is a POSIX system call while cd is a normal function used in a program which in this case is the shell.
In practice, chdir is called by cd to make the change in directory since the program does not have kernel privileges to do it by itself.