Fcntl 모듈을 import 하면 모드 상수값과 S_IF*/S_IS* 함수를 사용해서 파일모드와 종류를 테스트 할 수 있다.
예제
#!/usr/bin/perl
use File::stat;
use Fcntl ':mode';
my $finfo;
$finfo = stat($ARGV[0]) || die("cannot open file : $ARGV[0]\n");
printf "File Name are %s\n", $ARGV[0];
printf "File Size are %d\n", $finfo->size;
printf "Permission are %04o\n", $finfo->mode & 07777;
printf "File Size are %d\n", $finfo->size;
if (S_IRGRP & $finfo->mode)
{
printf("oK Group Read\n");
}
if (S_ISFIFO($finfo->mode))
{
printf("FIFO File\n");
}
stat
예제
Recent Posts
Archive Posts
Tags