(PUP-1144) Improve handling of underscore in variable names

The last segment of a qualified variable name is allowed to start
with an underscore. Previously this was only allowed for a single
segment.