-2

I have an old perl script that doesn't run properly anymore, outputting

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.

Instead of trying to fix the script, is there an easy way to interpret it 'as old'?

Toothrot
  • 334
  • 2
  • 10
  • http://perldoc.perl.org/functions/use.html – teodozjan Nov 15 '16 at 12:35
  • Did you update your Perl to a much newer version recently? – simbabque Nov 15 '16 at 12:35
  • @simbabque, I think this used to work before I switched from osx to Linux, but I don't know which version of Perl was installed then. – Toothrot Nov 15 '16 at 12:46
  • 1
    `defined(@array)` has never been correct. A list of values can't be "undefined", only "empty". It would be simple and preferable to change `defined(@array)` to `@array` throughout. – Borodin Nov 15 '16 at 12:54
  • @Borodin, that may be, but this isn't my script, it's big, and I'm not a programmer; I just want it to work like it used to. – Toothrot Nov 15 '16 at 12:59
  • 1
    @Toothrot: Then it sounds like you need to hire a programmer. – Borodin Nov 15 '16 at 13:04
  • @teodozjan: It think you misunderstand what use VERSION does. It defines the minimum version of Perl required to run a program. It doesn't revert Perl's syntax to an older version. – Dave Cross Nov 15 '16 at 13:31

1 Answers1

4

This is a change that was introduced in Perl 5.22:

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.

This syntax never made sense, so it was good to remove it.

As for how to fix it, well that really depends what the original programmer's intention was, and we can't know that without seeing more of the code. But the suggestion in the error message is probably a good start.

Update: I've just noticed this in the error message:

at /usr/local/diogenes/perl/CPAN/CGI.pm line 449

So the problem is in a library that your program uses. This problem doesn't seem to be in the most recent version of CGI.pm, so perhaps you could start by updating that.

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