http://qs321.pair.com?node_id=629295


in reply to Re^2: Split a string based on change of character
in thread Split a string based on change of character

I never thought of
grep $i=!$i,
before. I usually use
grep $i^=$i,

Yours is easier to understand, though.

Update: Yeah, I mean grep $i^=1,.

Replies are listed 'Best First'.
Re^4: Split a string based on change of character
by Skeeve (Parson) on Jul 28, 2007 at 15:28 UTC

    But $i^=$i makes $i 0 at once. So it's different to $i=!$i

    Back in the ancient times of C64 Basic I used j=1-j


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

      I think ikegami meant $i^=1, i.e.:

      my @words = grep $i^=1, split /(?<=(.))(?!\1)/, $string;
      which does work.