Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to efficently pack a string of 63 characters

by Discipulus (Canon)
on Sep 09, 2021 at 12:12 UTC ( [id://11136609]=note: print w/replies, xml ) Need Help??


in reply to How to efficently pack a string of 63 characters

Hello baxy77bax,

sorry for my naive suggestion, infact is not at all my field (well.. what is my field? ;) but what about something like:

use strict; use warnings; my @str = qw( ABBCBCAAAAABBCBCACCCAAAAACAAAAABBBBBAAAAABBAAAAAAAABBCCCACCAABC BCCCBCAACAABBBCAAACCAAAAACAAAAABBBBBAAAAABBAAAAAAAABBCCCACCABBC ABCCBBBAAAABBABCACABCCCCCCAAAAABBCBBCCCCAAAAAAAAAAAAACCCACCACCC ); foreach my $str ( @str ){ print "$str\n", $str =~ s/([A-C])(\1{2,})/$1.(1+length($2))/reg, "\n\n"; } __END__ ABBCBCAAAAABBCBCACCCAAAAACAAAAABBBBBAAAAABBAAAAAAAABBCCCACCAABC ABBCBCA5BBCBCAC3A5CA5B5A5BBA8BBC3ACCAABC BCCCBCAACAABBBCAAACCAAAAACAAAAABBBBBAAAAABBAAAAAAAABBCCCACCABBC BC3BCAACAAB3CA3CCA5CA5B5A5BBA8BBC3ACCABBC ABCCBBBAAAABBABCACABCCCCCCAAAAABBCBBCCCCAAAAAAAAAAAAACCCACCACCC ABCCB3A4BBABCACABC6A5BBCBBC4A13C3ACCAC3

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: How to efficently pack a string of 63 characters
by LanX (Saint) on Sep 09, 2021 at 12:54 UTC
    Yes but runlength encoding (+ Huffman) is already part of zip

    See http://www.zlib.net/feldspar.html

    The only chance to improve zip is to compress redundancy which isn't found by zip while providing an input which is character based (which you are doing)

    That's why I suggested a line delta compression first in my other answer, provided the example was real (which is not a given with this OP)

    See Re: How to efficently pack a string of 63 characters

    (There is a chance tho that zip is clever enough to notice such repeating groups too. But that kind of stuff is normally part of image not text compression)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-24 02:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found