caa@com50.c2s.mn.org (Charles Anderson) (06/25/91)
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)
lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) (06/26/91)
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