I'm not sure what the specific problem is in this case, but I would bet that this code isn't doing what you intended.

The lock() function is for use in threaded applications. It does not lock files.

The discussion that was linked to describes a bunch of CGI scripts, which typically aren't multi-threaded, so I would assume that what's intended is a file lock, to prevent inter-process conflicts, rather than a variable lock, to prevent inter-thread conflicts within a single process.

See the flock function instead.

Update: I've downloaded and looked around the code from the webapp site linked to above, and found that it does define a lock() function that in turns calls the built-in flock().

Perhaps the problem is that for some reason the cgi-lib/forum.pl file is being loaded before cgi-lib/subs.pl?

As a longer-term solution, you might find that renaming the lock function in subs.pl to lock_file, and similarly changing all of the calls to match, might be sufficient to fix it.


In reply to Re: Has the "require" functionality changed in Perl 5.8.1? by simonm
in thread Has the "require" functionality changed in Perl 5.8.1? by Alatar

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.