Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: best way to keep a simple count?

by Anonymous Monk
on Apr 11, 2005 at 13:46 UTC ( [id://446595]=note: print w/replies, xml ) Need Help??


in reply to best way to keep a simple count?

From the shell:
echo $((`cat counter` + 1)) > counter

Replies are listed 'Best First'.
Re^2: best way to keep a simple count?
by adrianh (Chancellor) on Apr 11, 2005 at 13:56 UTC
        echo $((`cat counter` + 1)) > counter

    Which won't work well if there can be multiple instances of the program running at the same time.

      I never claimed it was. And it wasn't the first suggestion in this thread that might fail if multiple instances of the program are running at the same time. (Well, technically, having multiple instances of the program running at the same time isn't the problem - the problem is them executing the one line of code at the same time).

      Code Pendants question was vague. He just wanted to know what other people used. He didn't state anything specific about his situation. Other than the implicite suggestion the program is started once a day (so, no multiple occurences).

      Here's another one-liner you can list faults for:

      perl -pi -le '$_++' counter

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found