Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!sdd.hp.com!caen!spool.mu.edu!cs.umn.edu!kksys!pwcs!com50!caa From: caa@com50.c2s.mn.org (Charles Anderson) Newsgroups: comp.lang.perl Subject: RLE compression in perl Message-ID: <1991Jun24.203454.20218@com50.c2s.mn.org> Date: 24 Jun 91 20:34:54 GMT Organization: Com Squared Systems, Inc. Lines: 26 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??? Thanks, -Charlie -- /-Charles-Anderson-\ | caa@c2s.mn.org || caa@midgard.mn.org \------------------/ | Com Squared Systems, voice (612) 452-9522 The rose goes in front | 1285 Corporate Center Drive fax (612) 452-3607 big guy -Crash Davis | Suite 170 | Eagan, MN 55121 (I speak for myself)