Recently trying to write a script that is designed to move files based on timestamps. I am fairly new to Perl, so please bare with me. I have written a short script that should iterate through all files in the current directory and output unix epoch time. The script in it's entirety is posted below:
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl
- use warnings;
- use strict;
- use Cwd;
- use File::Find;
- use File::Path;
- use File::stat;
- use Time::Local;
- my $sourceDir = getcwd;
- opendir DIR, $sourceDir or die "cannot open dir $sourceDir: $!";
- print "Source Dir: $sourceDir\n";
- my @file = readdir DIR;
- closedir DIR;
- print "Attempting to read files.\n\n";
- chdir($sourceDir);
- foreach my $file (@file)
- {
- print "file in loop: $file.\n";
- my $unixT = (stat($file))[9];
- print "Attempting to print stat: $unixT \n";
- }