Move in the catalog book
ChDir Changes the current working directory. It is similar to the CD command in the Shell :
ChDir '/etc ' or die "cannot chdir to/etc:$1";
Note: The working directory cannot be changed, meaning that the Perl program will return to its working directory.
If chdir is called without arguments,Perl will guess that it wants to go back to the user's home directory and set the working directory to the home directory, which is used without parameters under the shell. the cd command works the same.
Note: You cannot use tilde ~.
File name wildcard
Form:echo *.pm; where wildcard characters are * . The same applies in Perl:
My @all_files =glob ' * ';
My @pm_files =glob ' *.pm ';
where@all_files gets all the files in the current directory and sorts them alphabetically, but does not include files that begin with a dot, which is exactly the same as the practice in the shell (LS) .
Another syntax for file wildcard
Use <> complete glob functions, such as:
My @all_files =<*>;# effect is equivalent to : my @all_files =glob "*";
Perl Learning notes-Directory operations