in reply to Re: Filtering array of strings and numbers
in thread Filtering array of strings and numbers
Update: The undef issue that Athanasius pointed out can be avoided by adding a defined check in the grep:
grep {defined && $string_or_number ne $_} @strings_or_numbers;/Update
++. This is so elegantly simple it hurts :)
I was just in a situation the other day where I had to do the same thing as the OP, and it didn't even cross my mind to stringify like that.
These simple tricks are often the ones that one doesn't think about or forgets about when their head is wrapped around larger problems.
|
|---|