pos doesn't apply to s/// just like it doesn't apply to pack/unpack or anything else. pos only talks about m//g and that is the only thing that it applies to.
No question about it. However, the nature of how m// and s/// appears, and how they are documented closely together, makes them appear much more closely related, which would also allow them to share this particular characteristic -- especially in the context of "progressive matching." Remember, the frame of mind that someone is in when they think "progressive" is to "match-operate-match-operate, etc." Since m// lets you do that in a while loop, it seems reasonable to (at least) suspect that maybe s/// would do it too. By contrast, one wouldn't expect to apply to pack/unpack "or anything else" (as you put it) because those functions don't look so similar. Those are conceptually different.

if nothing else, I think it warrants comment in documentation that pos can be reset if used with s///, "or any other operation that may change the string, even if that change occurs later in the string than pos points to."

FWIW, I look forward to learning about your perl module that you described. It does seem to acknowledge the need for what I suspected to be true (or "should have been true." :-)


In reply to Re^8: Progressive matching w/substitutions (pos) by argv
in thread Progressive matching w/substitutions by argv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.