use strict; use warnings; use Carp qw( carp ); sub get_mtime { my ($file) = @_; if (! -e $file) { carp "There exists no such file as '$file'"; return undef; }; if (! -f $file) { carp "There exists '$file' but it isn't a file."; return undef; }; my $result = (stat $file)[9]; carp $! if $!; $result; }; my @files = qw( c:\\winnt\\cmd.exe c:\\winnt\\system32\\cmd.exe c:\\winnt ); for my $f (@files) { printf "'%s' has the mtime %s\n", $f, (get_mtime($f) || 'n/a'); };