Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: RLE compression in perl Message-ID: <1991Jun25.170245.3867@jpl-devvax.jpl.nasa.gov> Date: 25 Jun 91 17:02:45 GMT References: <1991Jun24.203454.20218@com50.c2s.mn.org> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 24 In article <1991Jun24.203454.20218@com50.c2s.mn.org> caa@com50.c2s.mn.org (Charles Anderson) writes: : : I'm trying to get perl to a simple form of RLE compression with the : substitution operator like this: : #!/usr/local/bin/perl : open(TXT, '> test.txt'); : while (<>) { : ($buf = $_) =~ s/(.)\1{2,126}/sprintf("%c%c", length($&) + 128, $1)/ge; : print TXT $buf; : } : close(TXT); : : I want to match any character then match 2 or more of the same character : and replace it with the length of the matched string with the high bit : set and the matched character.....to which perl tells me this: : : /(.)\1{2,126}/: internal regexp foulup at rle.pl line 4, <> line 1. : : Is this a bug or am I doing something wrong??? It's a bug. I hope to fix it "right" (meaning "efficiently") in the next patch, but as a (rather slow) workaround, you can put parens around the \1. Larry