当前位置: 首页 > 文档资料 > Perl 入门教程 >

chdir

优质
小牛编辑
129浏览
2023-12-01

描述 (Description)

此函数将当前工作目录更改为EXPR,如果未指定,则更改为用户的主目录。 此函数调用相当于Unix命令cd EXPR

语法 (Syntax)

以下是此函数的简单语法 -

chdir EXPR
chdir

返回值 (Return Value)

此函数在失败时返回0,在成功时返回1。

例子 (Example)

以下是显示其基本用法的示例代码,假设您正在/ user/home/xnip目录中工作 -

#!/usr/bin/perl
chdir "/usr/home";
# Now you are in /usr/home dir.
chdir;
# Now you are in home directory /user/home/xnip
<!--

When above code is executed, it produces the following result −

-->