如何使用perl进入目录? [英] How do I cd into a directory using perl?
本文介绍了如何使用perl进入目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试以下方法. 系统"cd directoryfolder" 但是失败了,我也尝试系统退出"离开终端,但是失败了.
I am trying the following.. system "cd directoryfolder" but it fails, also I try system "exit" to leave the terminal but it fails.
推荐答案
代码:
chdir('path/to/dir') or die "$!";
Perldoc:
chdir EXPR
chdir FILEHANDLE
chdir DIRHANDLE
chdir Changes the working directory to EXPR, if possible. If EXPR is omitted,
changes to the directory specified by $ENV{HOME}, if set; if not, changes to
the directory specified by $ENV{LOGDIR}. (Under VMS, the variable
$ENV{SYS$LOGIN} is also checked, and used if it is set.) If neither is set,
"chdir" does nothing. It returns true upon success, false otherwise. See the
example under "die".
On systems that support fchdir, you might pass a file handle or directory
handle as argument. On systems that don't support fchdir, passing handles
produces a fatal error at run time.
这篇关于如何使用perl进入目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文