# File lib/Getopt/DelimScanner.rb, line 1022
    def matchVariable( prefix )
        startPos = self.pointer
        debugMsg 2, "matchVariable starting at pos = %d: prefix = %s",
                 startPos, prefix.inspect

        # Look for the prefix

        raise MatchFailure, "Did not find prefix: /#{prefix.inspect}/" unless
            self.skip( prefix )

        varPos = self.pointer

        # If the variable matched is a predefined global, no need to look for an

        # identifier

        unless self.scan( %r~\$(?:[!@/\\,;.<>$?:_\~&`'+]|-\w|\d+)~ )

            debugMsg 2, "Not a predefined global at '%s...' (offset %d)" %
                [ self.rest[0,20].chomp, self.pointer ]
            
            # Look for a valid identifier

            unless self.scan( /\*?(?:[$@]|::)?(?:[a-z_]\w*(?:::\s*))*[_a-z]\w*/is )
                raise MatchFailure, "No variable found: Bad identifier (offset %d)" % self.pointer
            end
        end

        debugMsg 2, "Matched '%s' at offset %d" % [ self.matched, self.pointer ]

        # Match methodchain with trailing codeblock

        while self.rest?
            # Match a regular chained method

            next if scanCodeblock( {"("=>")", "do"=>"end", "begin"=>"end", "{"=>"}"},
                                   /\s*(?:\.|::)\s*[a-zA-Z_]\w+\s*/ )

            # Match a trailing block or an element ref

            next if scanCodeblock( nil, /\s*/, {'{' => '}', '[' => ']'} )

            # This matched a dereferencer in Perl, which doesn't have any

            # equivalent in Ruby.

            #next if scanVariable( '\s*(\.|::)\s*' )


            # Match a method call without parens (?)

            next if self.scan( '\s*(\.|::)\s*\w+(?![{(\[])' )

            break
        end

        rval = {
            :match  => self.string[ varPos .. (self.pointer - 1) ],
            :prefix => self.string[ startPos, (varPos-startPos) ],
            :suffix => self.string[ self.pointer..-1 ],
        }
        debugMsg 1, "matchVariable succeeded: %s" % rval.inspect
        return rval
    end