Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Split a string based on change of character

by ikegami (Pope)
on Jul 28, 2007 at 15:02 UTC ( #629295=note: print w/ replies, xml ) Need Help??


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,.


Comment on Re^3: Split a string based on change of character
Select or Download Code
Re^4: Split a string based on change of character
by Skeeve (Vicar) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://629295]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-12-29 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (187 votes), past polls