#!/usr/bin/perl use File::stat; # Declare variables my $filename; my $FILE_HANDLE; my $file_stat; my $current_time; my $diff_seconds; $filename = '/path/of/file/filename.ext'; # Open the file open ($FILE_HANDLE, $filename) or die "Can't open $filename!"; # Get the file status structure $file_stat = stat($FILE_HANDLE); # Get the current time $current_time = time; # Get the elapsed time in seconds $diff_seconds = time - $file_stat->mtime; # Do whatever you want with the $diff_seconds print "\n$filename was modified $diff_seconds seconds back.\n"; # All done