Hello all,
I have been working on a report generating script for the past week, and I've put 60ish hours in on it (which is a first for me, normally don't work that often), so my brain is bleeding.
As part of the feature creep that is intruding on this program, I have been asked to increment the outfiles that my code is creating, saving 7 copies in addition to the one that I am writing. They want/need the first (most recent) file to be file_name.0 - with the oldest being file_name.7.
Below I have some working code, but it seems very ugly. This is my first pass at it, and I'm sure it could be better, but as mentioned, I'm not thinking clearly any more, and could sure use some help.
my @files = <file_name.*>;
foreach (reverse @files)
{
my $temp = $1 if /.*\.([0-6])$/;
$temp++;
my $old = $_;
s/(.*\.)[0-6]$/$1$temp/;
rename $old, $_;
}