+ -
当前位置:首页 → 问答吧 → 关于perl中使用-M $file的问题

关于perl中使用-M $file的问题

时间:2011-11-25

来源:互联网

Perl code

#!/usr/bin/perl -w

$file="c:/readtest.txt";# Is it readble, writeable, and executable?print "File is readable, writeable, and executable\n" if -r $file and -w _ and -x _;# When was it last modified?print "File was last modified ",-M $file, " days ago.\n";#若为目录则打印print "File is a directory.\n " if -d $file; # Is it a directory?

print "File is readable, writeable, and executable\n" if -r $file and -w _ and -x _;
print "File was last modified ",-M $file, " days ago.\n";
print "File is a directory.\n " if -d $file; # Is it a directory?


最后显示结果是
Use of uninitialized value in print at C:\Program Files\ActiveState Komodo IDE 5\project\test1.pl line 6.
File was last modified days ago.
貌似-M $file并没有起作用 这是怎么回事呢?

作者: stevensunwang   发布时间: 2011-11-25

Perl code

print "File was last modified ",-M _, " days ago.\n" if -e $file;



$file 不存在就会出现这样的结果

作者: ccdbg   发布时间: 2011-11-25