in reply to Rolling variable

Add this one liner to your scheduler to run hourly, and the last 8 counts will be found in the file counts:

perl -i'*' -anle"@f=<c:/test/*>; shift @F; push @F, scalar @f; print j +oin ' ', @F;" counts

Update:You do have to prime the counts file:

echo 0 0 0 0 0 0 0 0 > counts

Anyone got any experience of this phone's predecessor?

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

Replies are listed 'Best First'.
Re^2: Rolling variable
by 1nickt (Canon) on Jul 30, 2015 at 16:42 UTC

    The first time you run this you will get an error because the file counts doesn't exist.

    Also, do you mean to have both @F and @f?

    Running this on my machine adds nothing to the file.

    $ pwd /Users/nick/monks $ ls | wc -l 39 $ perl -i'*' -anle"@f=</Users/nick/monks/*>; shift @F; push @F, scalar + @f; print join ' ', @F;" counts $ cat counts $
    The way forward always starts with a minimal test.
      The first time you run this you will get an error because the file counts doesn't exist.

      Yep. You need to prime it:echo 0 0 0 0 0 0 0 0 >counts

      do you mean to have both @F and @f?

      Yes. @F comes from -a (autosplit: see perlrun). @f is the array that gets the list of files; rename to your preference.


      Anyone got any experience of this phone's predecessor?

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.
      I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

        It's rather a large omission to leave off half of the job ("priming" the file). I would have thought it merited an "oh crap, you're right, I forgot to say ..." rather than a "yep". Surely you don't mean to imply that anyone reading your one-liner should have known how to "prime" the file?

        Perhaps you can look at that one-liner and read it without thinking about it. Most people can't. I don't see the benefit to making code so concise that you have to refer to documentation to decipher it when you revisit crontab in a couple of months. In the case of a novice programmer asking for advice on how to perform a simple task, it seems to be mostly grandstanding, and is not helpful. If you want to share advanced techniques in a thread such as this, you should explain them.

        The way forward always starts with a minimal test.
Re^2: Rolling variable
by fishmonger (Chaplain) on Jul 30, 2015 at 16:41 UTC

    Does not work as expected in my test.

    (1) It assumes that the counts file already exists, which it may not.
    (2) If the file is there but empty, it doesn't add anything to the file.
    (3) It changes all lines to the same value.