Please don't use this code.

Please don't give this code your ++ votes.

This code has obvious holes. It is neither functional, nor necessary.

There are ways of executing "atomic" test-and-set operations in every operating system, and this code does not use any of them. This code has windows of vulnerability. It's not a matter of whether or not you'll get burned, but when.

Do not use this code.

-- Randal L. Schwartz, Perl hacker


UPDATE: Hey, to the losers who downvoted this node, next time you get broken in or you can't get your code to work, just remember what you think of expert advice. {sigh} If you don't want me watching your backside, I won't waste my time. I just wish you would have enough guts to tell me to my e-face. Not just -- this node.

And a few people were kind enough to ask me to post references to how it should be done. Most of the first dozen hits I examined by a simple google for "perl lock" were very well written and don't suffer the problems of the code above. I don't think I should need to add instructions about google-ing to every node I write. {sigh}


In reply to DON'T USE THIS CODE by merlyn
in thread File::DumbLock by PodMaster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.