in reply to Can a defined value be of zero length?

I guess you could almost rewrite your test:
last unless $pattern;
except that it would return a different result if the user input is 0 or "0".