in reply to Getting modified date for a file (Win32)

Most likely, you are running without warnings and are not error-checking your results. My guess is, as you don't show how $file gets filled, that a file with the name in $file does not exist.

You will need to modify your code to track down this error, preferrably as follows:

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'); };

While that code is overly verbose, it should help you much with diagnosing the real cause of your error.