(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.
Merge pull request #2399 from hlindberg/pup-1144_underscore-in-last-segment

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