<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[BOL: Compress and decompress the sequence with perl]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/33547/compress-and-decompress-the-sequence-with-perl?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/33547/compress-and-decompress-the-sequence-with-perl?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/33547/compress-and-decompress-the-sequence-with-perl</guid>
	<pubDate>Fri, 16 Jun 2017 09:39:26 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/33547/compress-and-decompress-the-sequence-with-perl</link>
	<title><![CDATA[Compress and decompress the sequence with perl]]></title>
	<description><![CDATA[<code>use strict;
use warnings;

my @char;
while (&lt;DATA&gt;) {
@char = split //;
}

comp(\@char);
#---------------------
my $com= &quot;r0a3m4a4j0&quot;;
my @com = split //, $com;
dcomp (\@com);

#dcomp sub here
sub dcomp {
my ($com_ref)=@_;
my @com=@$com_ref;
my $car;
for (my $aa=0; $aa&lt;=$#com; $aa++) {
	if ($com[$aa]!~ /\D/) { print &quot;$car&quot; x ($com[$aa]);} else {print &quot;$com[$aa]&quot;; $car = &quot;$com[$aa]&quot;;}
}
print &quot;\n&quot;;
}

#comp sub here
sub comp {
my ($char_ref)=@_;
my @char=@$char_ref;
my $cnt=&quot;&quot;;
for (my $aa=0; $aa&lt;=$#char; $aa++) {
	if ($char[$aa+1]) {
		if ($char[$aa] eq $char[$aa+1]) { $cnt++; }  
		elsif ($cnt) { print &quot;$char[$aa]&quot;.&quot;$cnt&quot;; undef $cnt;}
		else {print &quot;$char[$aa]&quot;;}
	}
}
print &quot;\n&quot;;
}
__DATA__
raaaammmmmaaaaaj</code>]]></description>
	<dc:creator>Jit</dc:creator>
</item>

</channel>
</rss>