<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Counting the occurrences of a substring - the fastest way&#8230;</title>
	<link>http://www.chengfu.net/2005/10/count-occurrences-perl/</link>
	<description>Coding for fun</description>
	<pubDate>Sun, 06 Jul 2008 20:25:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>

	<item>
		<title>By: chengfu</title>
		<link>http://www.chengfu.net/2005/10/count-occurrences-perl/#comment-7</link>
		<author>chengfu</author>
		<pubDate>Sat, 26 Nov 2005 17:34:32 +0000</pubDate>
		<guid>http://www.chengfu.net/2005/10/count-occurrences-perl/#comment-7</guid>
		<description>Good point, I didn't realize that error. But as far as I can see this would only make the advantage of tr/// bigger, so the overall result at least isn't wrong.</description>
		<content:encoded><![CDATA[<p>Good point, I didn&#8217;t realize that error. But as far as I can see this would only make the advantage of tr/// bigger, so the overall result at least isn&#8217;t wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.chengfu.net/2005/10/count-occurrences-perl/#comment-5</link>
		<author>Mike</author>
		<pubDate>Sat, 26 Nov 2005 01:17:12 +0000</pubDate>
		<guid>http://www.chengfu.net/2005/10/count-occurrences-perl/#comment-5</guid>
		<description>The fastest way to count the occurrence of a one character literal substring is using the tr///.

Why do you add one to the result when it will then calculate one more than the number of literals found?

code:
my $string="1-4-7-8-37-5-7-8-3-42";
my $size = $string =~ tr/-//;
print "size = $size";

results:
size = 9</description>
		<content:encoded><![CDATA[<p>The fastest way to count the occurrence of a one character literal substring is using the tr///.</p>
<p>Why do you add one to the result when it will then calculate one more than the number of literals found?</p>
<p>code:<br />
my $string=&#8221;1-4-7-8-37-5-7-8-3-42&#8243;;<br />
my $size = $string =~ tr/-//;<br />
print &#8220;size = $size&#8221;;</p>
<p>results:<br />
size = 9</p>
]]></content:encoded>
	</item>
</channel>
</rss>
