in reply to Re^2: zero-length match increments pos()
in thread zero-length match increments pos()

If //c does that, I would call it a bug. Can you show a short test case? In at least this simple case, the flag (called MINMATCH, i.e. a minimum length of 1 will be required on the next match) is set:
$ perl -we'use Devel::Peek; ($x="abc")=~/.??/gc; Dump $x' SV = PVMG(0x10183f00) at 0x10167ca4 REFCNT = 1 FLAGS = (SMG,POK,pPOK) IV = 0 NV = 0 PV = 0x10142828 "abc"\0 CUR = 3 LEN = 4 MAGIC = 0x10147380 MG_VIRTUAL = &PL_vtbl_mglob MG_TYPE = PERL_MAGIC_regex_global(g) MG_FLAGS = 0x01 MINMATCH
(Note that older perls have a bug where Devel::Peek doesn't correctly show the flag by name, but you can still see the bit in MG_FLAGS.)

Replies are listed 'Best First'.
Re^4: zero-length match increments pos()
by tilly (Archbishop) on Feb 22, 2005 at 09:30 UTC
    Gah, you're right. I misremembered what the /c patch did. It is documented in Regexp Quotelike Operators, and it keeps pos from being reset on a failed match. So I was having to assign to pos before, but for a different reason than I was just remembering. :-(