Just some random thoughts on a napkin. Please do not shoot the messenger, but Perl would gain a lot in readability if it had reduced even more some of its generic constructs with better use of unambiguous context. For instance, who is in favor of a separate context type for hash arrays (associative arrays usually defined as %hasharrayname
), please raise your hands.
In a sheer reality we use following spaghetti code to iterate through the keys of a hash array:
foreach my $key ( keys %hasharr ) {
print $key, "\n";
}
In a better Perl world we could use something as follows to just print the keys (because hash array definition % is determined and unambiguous):
foreach my $key ( %hasharr ) {
print $key, "\n";
}
We wonder how many Perl beginners ever wrote something like this expecting to print out just the sorted keys:
foreach my $key (sort %hasharr) {
print $key, "\n";
}
..which is a clear recipe for a mishmash.
In a nutshell, why, oh, why do we have % when ( %hash
) and ( @hash
) being interpreted in an identical manner, as a list reference?
Update: after reading some Perl6 specifications, we think it would be better to put the subject of the syntax fixes aside. Perl6 “innovations” looks real nuts, end of Perl as we know it.