0

I've searched a couple of topics about this issue, and in the exact same context (running diogenes on linux) on the following link, but it was closed due to vagueness in the submission:

Running old perl script (2007)

So, the error message is this:

Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at /usr/local/diogenes/perl/CPAN/CGI.pm line 449.
Compilation failed in require at ./diogenes-server.pl line 42.
BEGIN failed--compilation aborted at ./diogenes-server.pl line 42.

At line 449 in CGI.pm there is this:

   if (defined(@QUERY_PARAM) && !defined($initializer)) {

So reading up a bit, it seems that this code is wrong and it has been deprecated in newer version of perl. Being Diogenes such an old software it seems correct. So, how can I rewrite this in order to move on.

Lastly, i am following this tutorial on how to run diogenes on linux and have no clue about perl programming: http://community.dur.ac.uk/p.j.heslin/Software/Diogenes/linux_install.php.

:)

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
user3303019
  • 142
  • 1
  • 11
  • Possible duplicate of [Perl error, cant use defined(@array). How can i fix this?](https://stackoverflow.com/questions/52708109/perl-error-cant-use-definedarray-how-can-i-fix-this) – Håkon Hægland Feb 17 '19 at 09:53

3 Answers3

3

As documented in defined (and mentioned in the error message), try changing this:

if (defined(@QUERY_PARAM) && !defined($initializer)) {

into this:

if (@QUERY_PARAM && !defined($initializer)) {
haukex
  • 2,973
  • 9
  • 21
  • This comes up:

    Software error:

    Unescaped left brace in regex is illegal here in regex; marked by <-- HERE 
        in m/xxbeginsamepage(?:\n\\nrm{ <-- HERE } \n)?/ at 
        /usr/local/diogenes/perl/Diogenes/Base.pm line 2769.
        Compilation failed in require at ./diogenes-server.pl line 52.
        BEGIN failed--compilation aborted at ./diogenes-server.pl line 52.
    – user3303019 Feb 16 '19 at 14:50
  • That's a different issue/question. Try putting a backslash \ in front of the `{` that it is complaining about. – haukex Feb 16 '19 at 14:51
  • Sorry, I don't understand. This is what comes up now and a buch of other stuff that doesnt' fir in a reply. Should I start a new post? – user3303019 Feb 16 '19 at 15:10
  • In `Diogenes/Base.pm`, on line 2769 through 2792, there are several `s#SSS#RRR#` expressions. In the `SSS` parts, change any `{` into `\{`. If that still doesn't help, then yes, post a new question. *Update:* Sorry, I was mistaken - it's only that one expression on line 2769 that is an issue, `nrm{}` should be changed to `nrm\{}`. – haukex Feb 16 '19 at 15:13
  • That did it! Thank you. This started the server and gave me a url, but doesn't work. Guess its for another topic. – user3303019 Feb 16 '19 at 15:30
2

The problem isn't really Diogenes itself. The problem is that Diogenes has packaged up all of the CPAN modules that it uses and that includes a version of CGI.pm from 2004.

That wouldn't be a problem, except that you're running this on a far newer version of Perl - Perl 5.22 or greater. The perldelta for Perl 5.22 includes this:

defined(@array) and defined(%hash) are now fatal errors

These have been deprecated since v5.6.1 and have raised deprecation warnings since v5.16.

So what's happening here is:

  • Diogenes includes a really old version of CGI.pm which uses deprecated syntax.
  • Diogenes doesn't include a version of the Perl compiler.
  • You are now using a version of Perl which has turned this deprecated syntax warning into a fatal error.

It looks like you have three options:

  • Downgrade to an earlier version of Perl (pre-5.22) which will just warn on this syntax.
  • Remove the Diogenes-installed copy of CGI.pm and install a recent version of CGI.pm from CPAN (version 3.60, released in 2012, fixed this bug).
  • Hack your Diogenes-installed copy of CGI.pm to replace defined(@QUERY_PARAM) with just @QUERY_PARAM.

In a comment, you mention trying the last suggestion on my list and getting a different problem. It looks like that's also caused by changes in Perl syntax (this time, regex syntax) in the twelve years since Diogenes was last updated. And, of course, it's possible that fixing that will just reveal another, similar, problem.

All in all, it might be worth contacting the author of Diogenes and explaining the problems you're having using the software with modern versions of Perl. Even if the author doesn't have time to fix the problems, it's possible that they could add a warning to the web site, telling people about these problems.

Dave Cross
  • 68,119
  • 3
  • 51
  • 97
-2

Try changing it to exists.

This also works if the purpose is to test for non-emptiness:

if (@QUERY_PARAM && !$initializer) {

aod
  • 155
  • 1
  • 5
  • 1
    `if` without parens looks like Perl 6, not Perl 5 syntax. Also, `!$initializer` is not the same as `!defined($initializer)`. And `exists` doesn't make sense here either. – haukex Feb 16 '19 at 14:43