I was surprised that this not only works, but also does not complain if strictures are added to the code. The code looks ingenious, but I wonder about two aspects: First, you are accessing a list one time as a hash via %NAME, and then the same list as an array, via @NAME. Is this considered accepted practice? Honestly, I hadn't expected it to work with lexically scoped variables, and I'm not sure whether this trick (if I can call it like this) will remain with later Perl versions.
A more serious problem is the line
@new{ @keys } = @orig{ @keys = grep /[adf]/, keys %orig };
where you rely on the fact that @keys gets its value first (from the grep) before it is used to form a slice for @new. I think this is undefined behaviour, isn't it?
--
Ronald Fischer <ynnor@mm.st>
|