midiperl has asked for the wisdom of the Perl Monks concerning the following question:

Problem with uninitialised value errors when using perlfunc '-M' option to obtain file timestamps

Windows OS environment

#filets.pl use strict; use warnings; use diagnostics; my $dir = 'subtest\\'; opendir(DIR, $dir) or die $!; while (my $file = readdir(DIR)) { print "$file has -M timestamp of:", -M $file, "\n"; } closedir(DIR)

***Sample Output***

. has -M timestamp of:0.0101967592592593

.. has -M timestamp of:6.89083333333333

Use of uninitialized value in print at filets.pl line 13 (#1)...

sub2.txt has -M timestamp of:

SubSample.txt has -M timestamp of:

***End of Sample Output***

Notes: the '-M' option works for me without problems for reading files located in the same directory where the perl script is located

I just can't seem to get it to work when reading files in another directory

Any help would be appreciated on how I can get '-M' option to work for files in a subdirectory

Replies are listed 'Best First'.
Re: perfunc -M option problem
by BrowserUk (Patriarch) on Jun 27, 2015 at 15:02 UTC

      Fantastic -- that worked beautifully! Thank you BrowserUk!!