Date::LastModified - Return last-modified date from a set of resources
use Date::LastModified; my $dlm = new Date::LastModified("CFGFILE"); my $dlm = new Date::LastModified( { "dlm_file" => [ "/www/data/index.html", "/www/data/iso9001/index.html" ] } ); $time = $dlm->last; # return last-modified time() format $string = $dlm->from; # return last-modified resource info
Date::LastModified extracts the last modification date from one or more resources, which can be files ("dlm_file"), directories ("dlm_dir"), or DBI-compatible databases ("dlm_dbi"). It should be possible to subclass Date::LastModified to add other resource types, like web pages or external sensors.
Date::LastModified uses AppConfig to parse the configuration file. To pass resources directly, specify them with a hashref to new() where the value is an array ref:
Looks at the file's last-modified date.
Looks at all the files in that directory and its subdirectories, using the latest file.
Looks at the database table and uses the last date for the specified field.
The time()-compatible time of the latest resource is returned by last().
Once last() has been called, you can obtain which resource was the last-modified by calling from(). If last() has not been called, from() returns undef.
Date::LastModified uses AppConfig to parse the configuration file, so you can specify the resources in one of two ways, either directly:
dlm_file = /etc/passwd dlm_dir = /www/data
or in a section:
[dlm] file = /etc/passwd dir = /www/data
Both styles result in the same outcome. The section style is useful if Date::LastModified will be used in a larger program that requires other configuration file info.
The $unix_time hashref supports a phrasebook pattern for extracting a time() from the database for comparisons. This hashref is where you can add database drivers, although these drivers are already supported:
Oracle (V7 & V8) MySQL (V3) SQLite (V2)
There is also a pseudo-entry "SQL92" that should have the correct syntax for SQL92-compatible databases like Oracle9i.
None by default.
DBI tests assume that the database(s) are updated regularly but not every minute or every second.
Mark Leighton Fisher, <mark-fisher@mindspring.com<gt>
perl.
To install Date::LastModified, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Date::LastModified
CPAN shell
perl -MCPAN -e shell install Date::LastModified
For more information on module installation, please visit the detailed CPAN module installation guide.