1File::stat(3pm)        Perl Programmers Reference Guide        File::stat(3pm)
2
3
4

NAME

6       File::stat - by-name interface to Perl's built-in stat() functions
7

SYNOPSIS

9        use File::stat;
10        $st = stat($file) or die "No $file: $!";
11        if ( ($st->mode & 0111) && $st->nlink > 1) ) {
12            print "$file is executable with lotsa links\n";
13        }
14
15        use File::stat qw(:FIELDS);
16        stat($file) or die "No $file: $!";
17        if ( ($st_mode & 0111) && ($st_nlink > 1) ) {
18            print "$file is executable with lotsa links\n";
19        }
20

DESCRIPTION

22       This module's default exports override the core stat() and lstat()
23       functions, replacing them with versions that return "File::stat"
24       objects.  This object has methods that return the similarly named
25       structure field name from the stat(2) function; namely, dev, ino, mode,
26       nlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, and blocks.
27
28       You may also import all the structure fields directly into your
29       namespace as regular variables using the :FIELDS import tag.  (Note
30       that this still overrides your stat() and lstat() functions.)  Access
31       these fields as variables named with a preceding "st_" in front their
32       method names.  Thus, "$stat_obj->dev()" corresponds to $st_dev if you
33       import the fields.
34
35       To access this functionality without the core overrides, pass the "use"
36       an empty import list, and then access function functions with their
37       full qualified names.  On the other hand, the built-ins are still
38       available via the "CORE::" pseudo-package.
39

BUGS

41       As of Perl 5.8.0 after using this module you cannot use the implicit $_
42       or the special filehandle "_" with stat() or lstat(), trying to do so
43       leads into strange errors.  The workaround is for $_ to be explicit
44
45           my $stat_obj = stat $_;
46
47       and for "_" to explicitly populate the object using the unexported and
48       undocumented populate() function with CORE::stat():
49
50           my $stat_obj = File::stat::populate(CORE::stat(_));
51

NOTE

53       While this class is currently implemented using the Class::Struct
54       module to build a struct-like class, you shouldn't rely upon this.
55

AUTHOR

57       Tom Christiansen
58
59
60
61perl v5.10.1                      2009-02-12                   File::stat(3pm)
Impressum