5 our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS);
9 @EXPORT = qw(stat lstat);
10 @EXPORT_OK = qw( $st_dev $st_ino $st_mode
11 $st_nlink $st_uid $st_gid
13 $st_atime $st_mtime $st_ctime
14 $st_blksize $st_blocks
16 %EXPORT_TAGS = ( FIELDS => [ @EXPORT_OK, @EXPORT ] );
20 # Class::Struct forbids use of @ISA
21 sub import { goto &Exporter::import }
24 struct 'File::stat' => [
26 dev ino mode nlink uid gid rdev size
27 atime mtime ctime blksize blocks
35 $st_dev, $st_ino, $st_mode, $st_nlink, $st_uid, $st_gid, $st_rdev,
36 $st_size, $st_atime, $st_mtime, $st_ctime, $st_blksize, $st_blocks )
41 sub lstat ($) { populate(CORE::lstat(shift)) }
45 my $st = populate(CORE::stat $arg);
49 return populate(CORE::stat \*{Symbol::qualify($arg)});
57 File::stat - by-name interface to Perl's built-in stat() functions
62 $st = stat($file) or die "No $file: $!";
63 if ( ($st->mode & 0111) && $st->nlink > 1) ) {
64 print "$file is executable with lotsa links\n";
67 use File::stat qw(:FIELDS);
68 stat($file) or die "No $file: $!";
69 if ( ($st_mode & 0111) && $st_nlink > 1) ) {
70 print "$file is executable with lotsa links\n";
75 This module's default exports override the core stat()
76 and lstat() functions, replacing them with versions that return
77 "File::stat" objects. This object has methods that
78 return the similarly named structure field name from the
79 stat(2) function; namely,
95 You may also import all the structure fields directly into your namespace
96 as regular variables using the :FIELDS import tag. (Note that this still
97 overrides your stat() and lstat() functions.) Access these fields as
98 variables named with a preceding C<st_> in front their method names.
99 Thus, C<$stat_obj-E<gt>dev()> corresponds to $st_dev if you import
102 To access this functionality without the core overrides,
103 pass the C<use> an empty import list, and then access
104 function functions with their full qualified names.
105 On the other hand, the built-ins are still available
106 via the C<CORE::> pseudo-package.
110 While this class is currently implemented using the Class::Struct
111 module to build a struct-like class, you shouldn't rely upon this.