in reply to Hash slice again
>perl -le"@a=qw(a b c d e); undef @a[2,3]; print for @a" a b c e
Update: Wait, I guess it didn't work for me. (Sorry, was rushed.) You can use this:
>perl -le"@a=qw(a b c d e); undef $_ for @a[2,3]; print for @a" a b e
The docs are quite specific as to what undef accepts for args. I would expect a built-in to complain if you gave it incorrect arguments, but that's what you are doing.
By the way, undef @h{@k}; is not allowed and doesn't work either.
$ perl -le"%h=map { $_=>$_ } qw(a b c d e); undef @h{qw( c d )}; print + qq{$_: $h{$_}} for sort keys %h" a: a b: b c: c d: e: e
|
|---|