For the answer from 08:53, "old" version of perl
means anything earlier than 5.004. What a great excuse to upgrade! :) Also, in the above code, you should check the return values of flock and seek. Finally, unlocking is not necessary - the close will release the lock quite nicely.
Here's an interesting quote from the fopen manpage:
If two separate processes open the same file for append,
each process may write freely to the file without fear
of destroying output being written by the other. The
output from the two processes will be intermixed in
the file in the order in which it is written.
Depends on your OS, of course, but most should be safe,
and do not necessarily need file locking (especially if
each process is only writing a single line to the file!)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.