in reply to sizeDateValidator.pl is horribly slow

First of all, you should use strict; and use warnings;.

On your first attempt, you do something like this:

$timestamp = POSIX::strftime("%m/%d/%Y %I:%M %p", localtime(( stat $fi +les)[9])); # or change localtime to gmtime $size = (stat $files)[7];

You run stat twice, forcing the operating system to grab the same data twice. Why?

Something like this should do the trick in less time:

# Get both pieces of information we need my ($size, $timestamp) = ((stat $files)[7, 9]); # Convert timestamp $timestamp = POSIX::strftime("%m/%d/%Y %I:%M %p", localtime($timestamp +);

Don't use '#ff0000':
use Acme::AutoColor; my $redcolor = RED();
All colors subject to change without notice.

Replies are listed 'Best First'.
Re^2: sizeDateValidator.pl is horribly slow
by msensay (Novice) on Nov 07, 2011 at 14:54 UTC
    Thanks cavac for bestowing your wisdom upon me. The script runs almost a minute faster on the 20K recordset I am using to test. Prior to your suggestion the script was taking 3minutes 15seconds, and now it runs in 2min 20 seconds. A very significant improvement.