in reply to Bug or feature? s/// and the g option

To those who call this "undefined behavior":

Just because it's not a very useful thing to do, doesn't mean it's not a bug. $1, etc., shouldn't be affected by unsuccessful matches. This is clearly spelled out in $& (which suffers the same bug as $1) even if $<_digits_> is for some reason missing the "successful" qualification.

  • Comment on Re: Bug or feature? s/// and the g option

Replies are listed 'Best First'.
Re^2: Bug or feature? s/// and the g option
by Cop (Initiate) on Oct 14, 2007 at 22:20 UTC

    Especially don't call it a feature.

    Some people might try to categorize this as hidden feature. My thought: although not stated itself, hidden feature cannot violate what's stated, i.e. must be logically consistent with the rest.

    The best way to verify whether something is a feature, obviously is to ask the creators, but if that's not feasible, my above logic applies.