Subject: | defined %foo and defined @foo an error |
Starting from perl 5.22 defined is no longer permitted on aggregates, ie. hashes and arrays.
This has been warning as deprecated since at least 5.12, since it's behaviour is non-obvious.
For an array or hash it doesn't check whether it has any elements, but whether some
internal data structures have been initialized, for example:
# perl 5.14.2
$ perl -M-warnings -le 'for (1 .. 2) { my %x; print 0+defined %x; print scalar keys %x; $x{abc} = 1 }'
0
0
1
0
The attached patch fixes the problem in Unix-ConfigFile.
Tony
Subject: | unix-configfile-defined.diff |
diff -ru Unix-ConfigFile-0.06-p7qUjC/AliasFile.pm Unix-ConfigFile-0.06-2t7dzt/AliasFile.pm
--- Unix-ConfigFile-0.06-p7qUjC/AliasFile.pm 2000-05-03 01:50:43.000000000 +1000
+++ Unix-ConfigFile-0.06-2t7dzt/AliasFile.pm 2015-03-30 15:20:00.000000000 +1100
@@ -213,7 +213,7 @@
}
my $name = $1;
my @users = $this->alias($name);
- next if !defined @users;
+ next if !@users;
print $fh $this->joinwrap(80, "$name: ", "\t", ",", ",", @users), "\n"
or return 0;
}
Only in Unix-ConfigFile-0.06-2t7dzt/: AliasFile.pm~