Perl 5.14.0 released
Posted May 15, 2011 21:17 UTC (Sun) by
jzbiciak (
✭ supporter ✭, #5246)
In reply to:
Perl 5.14.0 released by rpkelly
Parent article:
Perl 5.14.0 released
Interesting... I didn't realize 'keys' was now valid on an array. I was a little confused by the output you gave for the second example until I realized what was happening. This appears to be a 5.12 feature I missed. I tried the following on perl 5.10 and 5.12:
my @array = qw(fred barney);
print join(" ", keys @array), "\n";
Perl 5.10 gives what I would expect:
Type of arg 1 to keys must be hash (not private array) at keys.pl line 5, near "@array)"
Execution of keys.pl aborted due to compilation errors.
In contrast, Perl 5.12 gives:
0 1
Yet another feature I didn't know about, but now I can't wait to use, but have to wait to use until 5.8 truly dies at work.
It certainly ought to make it easier to traverse arbitrary nested structures, since you wouldn't have to know whether a given element contains an array or hash reference. For example, you could start developing your structures with arrays, and switch to hashes later if you discover you benefit from sparse or non-numeric keys, and not have to change a lot of code.
(
Log in to post comments)