2013-04-24 73 views
-2

我有以下脚本,用来读取在给定路径的文件!在此脚本中,我们假设很好的路径就像如何在Perl中处理文件路径?

chdir("/usr/test1/street/accounts/goal/routecab/Prpbict") 

工作,但

chdir("/usr/test1/street/accounts/goal/routecab/EventDir") 

的目录并没有改变!有谁能告诉我理由!

运行时间

dir_name=Event\ Based\Mailers_Registration_Welcome.htm 

的DIR_NAME追加到工作后的目录似乎:$main_dir=/usr/test1/site/accounts/coach/rulecab/Event\ Based\ Mailers_Registration_Welcome.htm 运行后: - chdir($main_dir);print PWD ;它将打印这本谈不上什么对其余的路径我的意思是DIR_NAME在/ usr/test1/site/accounts/coach/rulecab

+0

你能证明路径是正确的吗?在您的终端上添加'$ ls/usr/test1/street/accounts/goal/routecab/EventDir'的输出 – chrsblck 2013-04-24 15:00:03

+0

我可以手动找到这个目录! – 2013-04-24 15:02:58

+0

看到我正在运行这个脚本for循环!!!当一个可怕的开始与E来它将跳过剩余的路径在案件dir只改变/ usr/test1/street/accounts/goal/routecab/this单独的路径 – 2013-04-24 15:05:11

回答

1

我假设你有你的路径报价?

要了解为什么chdir失败,你应该写

chdir '/usr/test1/street/accounts/goal/routecab/EventDir' 
     or die "Unable to chdir: $!"; 

和Perl会告诉你原因。

+0

实际上这里是使用变量man!ex:-my $ PATH = '在/ usr/TEST1 /街道/帐号/目标/ routecab/EventDir'; chdir $ path或死“无法chdir:$!”; – 2013-04-24 15:15:50

+1

@Thiyagu ATR:它报道什么?是退出还是继续工作? – TrueY 2013-04-24 15:30:43

+0

它继续工作! – 2013-04-24 17:10:16