0
我是新来perl.Below是我的代码用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.
http://perldoc.perl.org/perlfunc.html#utime- LIST – TLP
与[如何在一行中如何接触文件和mkdir]类似(http://stackoverflow.com/q/28296411/1824796)。为什么[touch a directory](http://askubuntu.com/q/366780),只是创建它'perl -MFile :: Spec -e'mkdir File :: Spec-> catpath(undef,“/ tmp”, “dir001”)或死亡q(错误:不能这样做)''。 – Pavel
使用'use strict;使用警告;'在每个Perl脚本中。 – reinierpost