Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^8: Rolling variable

by fishmonger (Chaplain)
on Jul 30, 2015 at 16:00 UTC ( [id://1136886]=note: print w/replies, xml ) Need Help??


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

You left out a key portion of that quote.

(please correct me if I'm wrong)

The OP's assumption was wrong and your update should have included the correction.

You also skipped over his last sentence.
So I was thinking to save the counts in a file

And why copy the array resulting in 3 arrays only differing in the order of the elements? Only 1 array is needed. The others IMO just add unnecessary obfuscation and inefficiency.

Replies are listed 'Best First'.
Re^9: Rolling variable
by james28909 (Deacon) on Jul 30, 2015 at 17:40 UTC
    If he wanted to save the count "8" into a file, what would be the point? If he wanted the last 8 counts of the function, it will always return "8" would it not? If that was the case, he could just set $count to '8' and be done with it.

    Anyways, im not going to argue with anyone, it was merely an opinion/suggestion that I posted earlier and was not meant to start a war over something that could have been interpreted 5 different ways. Thanks for your insight though, I will keep it in mind for future reference.

      I believe the OP wanted effectively to list the files in a directory, get the count of the number of files, and save this number in a file. Per my recommended approach (Tie::File), each line in the store file would contain an integer of the number of files. This file would have eight lines (one per hour apparently). After the file hits eight lines, the top one (oldest) gets shifted off, and the most recent goes to the bottom.

      If he wanted to save the count "8" into a file, what would be the point? If he wanted the last 8 counts of the function, it will always return "8" would it not?

      You definitely are cherry pinking and misreading the OP's question and statements. He doesn't want to track the number of times a function or script is called. He want's to track the number of files in a directory over an 8 hour period. He didn't say his reason why, but that is what he wants.

      None of us are wanting or trying to argue. We're just trying to clear up some misunderstandings.

      Both mine and stevieb's suggestions accomplishes what the OP asked. Yours unfortunately does not.

        If he just needed a file count every hour and only keep the last 8 hours worth of file counts on any specific directory, he sure had a heck of a way of explaining it ;0

        Your right I completely misunderstood what he was asking and offered a irrelevant solution to his problem.
        Best reguards.

        :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1136886]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-19 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found