1. Perl
  2. Operators
  3. File test
  4. here

Get the number of days that have passed since the last access

To get the number of days that have passed since the last access, use the file test operator "-A".

-A $file

Example program

This is an example that uses the file operator -A to get the number of days that have passed since the last access.

use strict;
use warnings;

# Get the number of days that have passed since the last access (read).
# -A $file

print "1: Get the number of days that have passed since the last access.\n";
my $file = "a.txt";
if (-e $file) {
  my $from_last_access = -A $file;
  print "$from_last_access days have passed since the last access.\n";
}
else {print "$file does not exist.\n"}

Related Informatrion