in reply to Re^3: Rolling variable
in thread Rolling variable

This does not solve the prerequisite that the OP needs to access the list of file counts from an external source in between runs.

Also, there's no reason to have to use so many arrays and trickery. The following will remove the oldest addition after the array reaches a length of eight, and add a new one to the bottom of the list:

my @a = qw(1 2 3 4 5); for (1..5){ shift @a if @a == 8; push @a, 'new data'; } print "$_\n" for @a;

Replies are listed 'Best First'.
Re^5: Rolling variable
by james28909 (Deacon) on Jul 30, 2015 at 15:09 UTC
    Thanks, i will def keep that in mind. Honestly all i was trying to do was give some ideas. I didnt see anyone else post yet and was just giving ideas.
    EDIT: Also, the list of files could easily be written to a static spot in the file system.

      The OP did not say he needed to keep a list of files. The OP stated that the count of files is all that was wanted.

        I would like to keep only the last 8 counts, meaning throw away the oldest data & just keep the last 8 records.

        This could honestly be open to interpretation. I took it as what he really needed was the last 8 records thats currently in the directory. Anyways, Thanks for pointing that out, I retract any and all suggestions.

        EDIT: Hi James, Rata, Thanks for the inputs. However, I thin k this will work in a single run of the script

        Even the OP stated this would work, but he needed it to run every hour, so I modified it somewhat to show him another way. I am only giving suggestions/opinions/options in hopes it will make him think/tinker more and figure it out on his own. I also search for code and modify it as I need IF I cant figure it out myself.