【发布时间】:2015-11-05 15:36:13
【问题描述】:
我是 perl 新手。下面是我使用 perl 触摸目录的代码
#!/usr/bin/perl
# Populate the hashMap
# keys --> directories to clean
# attributes --> days to keep.
print "<-------------------------------------------------------->";
print " Touching of folders Started ";
touch `/tmp/dir1`;
touch `/tmp/dir2`;
print " Touching of folders Ended ";
print "<-------------------------------------------------------->";
运行脚本时出现以下语法错误。请帮忙。
$ ./FeedServerHscript.sh
Backticks found where operator expected at /tmp/eCAS_Housekeep/Ecas_54.pl line 11, near "touch `/tmp/dir1`"
(Do you need to predeclare touch?)
Backticks found where operator expected at /tmp/eCAS_Housekeep/Ecas_54.pl line 12, near "touch `/tmp/dir2`"
(Do you need to predeclare touch?)
syntax error at /tmp/eCAS_Housekeep/Ecas_54.pl line 11, near "touch `/tmp/dir1`"
Execution of /tmp/eCAS_Housekeep/Ecas_54.pl aborted due to compilation errors.
【问题讨论】:
-
类似于How to touch a file and mkdir if needed in one line。为什么touch a directory,只需创建它
perl -MFile::Spec -e 'mkdir File::Spec->catpath(undef, "/tmp", "dir001") or die q(err: cant do that)'。 -
在每个 Perl 脚本中使用
use strict; use warnings;。
标签: perl