I note the code I posted actually didn't even work for the first list.
I note this code does work and there's a few things in this that I don't know well, so good for learning, thank you.
presumably means if there is nothing in the array? This is a general confusion I have with perl, about what tests for a value being present in a variable and what "undef" means. I assume the exclamation mark I can always use to determine if values are (not) present in a variable from now on?
Colin