Alatar has asked for the wisdom of the Perl Monks concerning the following question:
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:
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.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();
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
|
|---|