in reply to Rolling variable

Your question is inconsistent. You want to keep a filecount (ls | wc -l) and record the count (>/some/dir/some.file). That is one count. Then you want to keep the 8 most recent counts? You only have one! Having said that, whatever you really mean, it sounds like something a simple shell script is better suited for than Perl, but not knowing the exact requirements, one cannot say definitely.