in reply to Moving files to subfolders based on their last modified date
Always use strictures (use strict; use warnings; - see The strictures, according to Seuss). Your major logic flaw (using $outdir before it is assigned a value) would have been caught by strictures.
Note that the $outdir flaw is more interesting than you might guess. Because $outdir is a package variable, and therefore a global variable, it remembers the last file's directory and uses it for the current one so most files will go to the wrong place!
|
|---|