I was wondering really, if it was possible to have a regular expression return 'null', in list context, and to have sort somehow not add the null to the sorted list. Does this make sense?
I presume you mean the match operator when you say regular expression.
And yes, that's possible. The match operator returns an empty list in list context for a failed match.
$ perl -le'print for map /^foo(.*)/, @ARGV' foobar foobaz dodo
bar
baz
The problem isn't what it returns when the match fails, it's what it returns when the match succeeds. You want it to return both the number and the entire string as one value, and that's not going to happen.