Hi,

I've been using a Perl portal (Web-App) for a while now and we've recently discovered a problem on certain servers. It looks like the problem is confined to servers that have Perl 5.8.1 installed. The problem seems to be concerned with either file locking, or more likely with require statements.

As an example, the index.cgi has a require statement that calls config.pl and a number of other files. This structure has worked well for us and is still working prefectly on many sites that have not upgraded to Perl 5.8.1, however, newer sites are returning the following error:

Software error:
Can't modify constant item in lock at index.cgi line 256, near "FILE)"
Execution of index.cgi aborted due to compilation errors.

I can provide code if necessary, but initially I'm looking for a general answer on whether this functionality has changed. I've looked on Perl.org but there seems to be no mention of this. It's very possible that the existing code was running in a sloppy fashion that has now become broken because Perl has tightened up it's definitions.

Any help much appreciated!
Alatar

As requested: here's the relevant code:

elsif ($action eq "forum") { $forum = qq~$cgi?action=forum&board=$currentboard~; if ($currentboard ne "" and $op eq "") { open(FILE, "$boardsdir/$currentboard.dat") || error("$err{'001 +'} $boardsdir/$currentboard.dat"); lock(FILE); chomp(@boardinfo=<FILE>); unlock(FILE); close(FILE); $boardname = "$boardinfo[0]"; $boardmoderator = "$boardinfo[2]"; open(MODERATOR, "$memberdir/$boardmoderator.dat"); lock(MODERATOR); chomp(@modprop = <MODERATOR>); unlock(MODERATOR); close(MODERATOR); $moderatorname = "$modprop[1]"; require "$sourcedir/forum.pl"; messageindex();
The error refers to the line "lock(FILE);" and the reason I think require might be the problem is because I think the global variables are not being carried through from the code called in the require statement.

Also, by previous version of Perl, I mean all different flavours. The only one that seems to have a problem is Perl 5.8.1


In reply to 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.