perl 文件读写详细说明

2019-10-01 15:10:06于丽
-g 是否设置了setgid位 -k 是否设置了sticky位 -l 是否为符号链接 -o 是否拥有该文件 -p 是否为管道 -r 是否可读 -s 是否非空 -t 是否表示终端 -u 是否设置了setuid位 -w 是否可写 -x 是否可执行 -z 是否为空文件 -A 距上次访问多长时间 -B 是否为二进制文件 -C 距上次访问文件的inode多长时间 -M 距上次修改多长时间 -O 是否只为“真正的用户”所拥有 -R 是否只有“真正的用户”可读 -S 是否为socket -T 是否为文本文件 -W 是否只有"真正的用户"可写 -X 是否只有"真正的用户"可执行 注:“真正的用户”指登录时指定的userid,与当前进程用户ID相对,命令suid可以改变有效用户ID。

  例:
    unless (open(INFILE, "infile")) {
    die ("Input file infile cannot be opened.n");
    }
    if (-e "outfile") {
    die ("Output file outfile already exists.n");
    }
    unless (open(OUTFILE, ">outfile")) {
    die ("Output file outfile cannot be opened.n");
    }
  等价于
    open(INFILE, "infile") && !(-e "outfile") &&
    open(OUTFILE, ">outfile") || die("Cannot open filesn");
五、命令行参数