|We don't bite newbies here... much|
keys with an expressionby morgon (Deacon)
|on Nov 20, 2013 at 09:47 UTC||Need Help??|
morgon has asked for the
wisdom of the Perl Monks concerning the following question:
this is a way to get the unique elements of an array:
I would like to do away with the temporary hash and would like to write the following seemingly natural perl-code:
But to my amazement this does not work with 5.18.1 - the error is "Type of argument to keys on reference must be unblessed hashref or arrayref".
I could swear this used to work some years ago (not really sure), so my question is how can I do this - how can I use keys with such an expression?
Is there really no way to avoid the ugly temporary?
Please note that the above is just an illustration - this is not a question about how to find unique array elements but a question concerning the kinds of expressions I can feed into keys.