On Mon, Apr 07, 2003 at 09:43:17PM +0100, Dave Mitchell wrote: > > ## Demonstrate a bug in perl 5.8 when the first key of a hash ref > > ## starts with the letter 'q' unquoted And here's a patch for the actual bug. It turns out that the hash / block disambiguator code in toke.c got confused when seeing "{ q". After looking for, and failing to find a q//-type construct, it wasn't going back and checking whether the thing starting with a q was a plain word instead. -- print+qq&$}$"$/$s$,$*${$}$g$s$@$.$q$,$:$.$q$^$,$@$*$~$;$.$q$m&if+map{m,^\d{0\,},,${$::{$'}}=chr($"+=$&||1)}q&10m22,42}6:17*2~2.3@3;^2$g3q/s"&=~m*\d\*.*g --- toke.c- Mon Apr 7 22:50:04 2003 +++ toke.c Mon Apr 7 22:52:35 2003 @@ -3210,6 +3210,7 @@ Perl_yylex(pTHX) || ((*t == 'q' || *t == 'x') && ++t < PL_bufend && !isALNUM(*t)))) { + /* skip q//-like construct */ char *tmps; char open, close, term; I32 brackets = 1; @@ -3237,8 +3238,12 @@ Perl_yylex(pTHX) else if (*t == open) brackets++; } + t++; } - t++; + else + /* skip plain q word */ + while (t < PL_bufend && isALNUM_lazy_if(t,UTF)) + t += UTF8SKIP(t); } else if (isALNUM_lazy_if(t,UTF)) { t += UTF8SKIP(t);Thread Previous | Thread Next