.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Path::Class::File::Stat 3pm" .TH Path::Class::File::Stat 3pm "2022-11-19" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Path::Class::File::Stat \- test whether the file beneath a Path::Class::File object has changed .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Path::Class::File::Stat; \& my $file = Path::Class::File::Stat\->new(\*(Aqpath\*(Aq,\*(Aqto\*(Aq,\*(Aqfile\*(Aq); \& \& # $file has all the magic of Path::Class::File \& \& # sometime later \& if ($file\->changed) { \& # do something provocative \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Path::Class::File::Stat is a simple extension of Path::Class::File. Path::Class::File::Stat is useful in long-running programs (as under mod_perl) where you might have a file handle opened and want to check if the underlying file has changed. .SH "METHODS" .IX Header "METHODS" Path::Class::File::Stat extends Path::Class::File objects in the following ways. .SS "use_md5" .IX Subsection "use_md5" Calling this method will attempt to load Digest::MD5 and use that in addition to \fBstat()\fR for creating file signatures. This is similar to how File::Modified works. .SS "changed" .IX Subsection "changed" Returns the previously cached File::stat object if the file's device number and inode number have changed, or if the modification time or size has changed, or if \fBuse_md5()\fR is on, the \s-1MD5\s0 signature of the file's contents has changed. .PP Returns 0 (false) otherwise. .PP While File::Modified uses a \s-1MD5\s0 signature of the \fBstat()\fR of a file to determine if the file has changed, \fBchanged()\fR uses a simpler (and probably more naive) algorithm. If you need a more sophisticated way of determining if a file has changed, use the \fBrestat()\fR method and compare the cached File::stat object it returns with the current File::stat object. .PP Example of your own \fBchanged()\fR logic: .PP .Vb 3 \& my $oldstat = $file\->restat; \& my $newstat = $file\->stat; \& # compare $oldstat and $newstat any way you like .Ve .PP Or just use File::Modified instead. .SS "restat" .IX Subsection "restat" Re-cache the File::stat object in the Path::Class::File::Stat object. Returns the previously cached File::stat object. .PP The \fBchanged()\fR method calls this method internally if \fBchanged()\fR is going to return true. .SH "SEE ALSO" .IX Header "SEE ALSO" Path::Class, Path::Class::File, File::Signature, File::Modified .SH "AUTHOR" .IX Header "AUTHOR" Peter Karman, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2006, 2013 by Peter Karman .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.