<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GeeksPlanet.net &#187; Perl</title>
	<atom:link href="http://geeksplanet.net/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://geeksplanet.net</link>
	<description>C, C++, JAVA, PERL programming for Dummies</description>
	<lastBuildDate>Wed, 24 Feb 2010 11:38:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A simple perl program to count the occurences of a string in a given text.</title>
		<link>http://geeksplanet.net/2009/07/perl/a-simple-perl-program-to-count-the-occurences-of-a-string-in-a-given-text/</link>
		<comments>http://geeksplanet.net/2009/07/perl/a-simple-perl-program-to-count-the-occurences-of-a-string-in-a-given-text/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 06:23:12 +0000</pubDate>
		<dc:creator>Satish Gandham</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[chop]]></category>
		<category><![CDATA[split]]></category>

		<guid isPermaLink="false">http://geeksplanet.net/?p=114</guid>
		<description><![CDATA[In this program we are going to use the split function in perl to count the occurrences of a particular string in a given text. Analysis In line 5, if we don&#8217;t add the blank space before and after the text, we will not be able to count the occurrence of the string at the [...]]]></description>
			<content:encoded><![CDATA[<p>In this program we are going to use the split function in perl to count the occurrences of a particular string in a given text.</p>
<pre class="brush: perl; title: ; notranslate">
#!/usr/bin/perl
#A perl program to count the occrrences of a particular string in a given text
print(&quot;Enter some text\n&quot;);
$text=&quot; &quot;.&lt;stdin&gt;.&quot; &quot;;
print(&quot;Enter the string whose occurrences you want to count:&quot;);
$string=&lt;stdin&gt;;
chop($string);
@array= split(/$string/,$text);
$count=@array;
print(&quot;\nThe number of occurrences of the string \&quot;$string\&quot; is &quot;. ($count-1).&quot;\n&quot;);
</pre>
<p><strong>Analysis</strong></p>
<p><strong>In line 5,</strong> if we don&#8217;t add the blank space before and after the text, we will not be able to count the occurrence of the string at the beginning and end.<br />
<strong>In line 7 </strong>we are <strong>chopping</strong> the string to get rid of the new line character at the end, if we don&#8217;t do this we wont get the count we are expecting.<br />
<strong>In line 8</strong> we are using the split function. <strong>Split</strong> is a library function, it splits the string when ever it see the sub string between //.<br />
for example @array=split(/the/, &#8220;this is a test string to, this string to split when ever there is an occurrence of the word this&#8221;);<br />
now the array will have the following elements<br />
<strong>$array[0]</strong>=&#8221; is a test string to, &#8221;<br />
<strong>$array[1]</strong>=&#8221;string to split when ever there is an occurrence of the word &#8220;</p>
]]></content:encoded>
			<wfw:commentRss>http://geeksplanet.net/2009/07/perl/a-simple-perl-program-to-count-the-occurences-of-a-string-in-a-given-text/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing perl and writing your first perl program in Ubuntu</title>
		<link>http://geeksplanet.net/2009/06/perl/installing-perl-and-writing-your-first-perl-program-in-ubuntu/</link>
		<comments>http://geeksplanet.net/2009/06/perl/installing-perl-and-writing-your-first-perl-program-in-ubuntu/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 11:43:24 +0000</pubDate>
		<dc:creator>Satish Gandham</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Installing perl]]></category>
		<category><![CDATA[Running a perl program]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://geeksplanet.net/?p=101</guid>
		<description><![CDATA[What Is Perl? Perl is an acronym, short for Practical Extraction and Report Language. It was designed by Larry Wall as a tool for writing programs in the UNIX environment and is continually being updated and maintained by him. For its many fans, Perl provides the best of several worlds. For instance: Perl has the [...]]]></description>
			<content:encoded><![CDATA[<h2><strong>What Is Perl?</strong></h2>
<p>Perl is an acronym, short for <strong>Practical Extraction and Report Language</strong>. It was designed by <strong>Larry Wall</strong> as a tool for writing programs in the UNIX environment and is continually being updated and maintained by him. For its many fans,</p>
<ul>
<li>Perl provides the best of several worlds. For instance: Perl has the power and flexibility of a high-level programming language such as <strong>C</strong>. In fact, as you will see, many of the features of the language are borrowed from C.</li>
<li>Like shell script languages, Perl does not require a special compiler and linker to turn the programs you write into working code. Instead, all you have to do is write the program and tell Perl to run it. This means that Perl is ideal for producing quick solutions to small programming problems, or for creating prototypes to test potential solutions to larger problems.</li>
<li>Perl provides all the features of the script languages <strong>sed</strong> and <strong>awk</strong>, plus features not found in either of these two languages. Perl also supports a <strong>sed-to-Perl</strong> translator and an <strong>awk-to-Perl</strong> translator.</li>
</ul>
<p><strong>In short, Perl is as powerful as C but as convenient as awk, sed, and shell scripts.</strong></p>
<h2><strong>How to install Perl on Ubuntu</strong></h2>
<p>Perl is located in the ubuntu repositories, you can install it by the following command.</p>
<blockquote><p>sudo apt-get install perl</p></blockquote>
<p>perl is installed in usr/bin/<br />
Writing your first perl program</p>
<pre class="brush: perl; title: ; notranslate">
#!/usr/bin/perl
# A simple perl program to print the user input
print (&quot;Hello, type in something\n&quot;);
$inputline=;
print ($inputline);
</pre>
<p>Lets split up the code and see what each line does..<br />
<strong>#!/usr/bin/perl</strong><br />
<strong># </strong>Says this line is a comment and there are no executable instructions on this line<br />
<strong>!</strong> Says this is a perl script<br />
/usr/bin/perl give the location of the perl interpreter, many programing books mention the location as <strong>usr/local/bin/perl</strong>, but this is not correct in ubuntu. In ubuntu Perl interpreter is located at usr/bin/perl.<br />
<strong>print &#8220;Hello, type in something\n&#8221;;</strong><br />
This line just prompts to user to type something, similar to printf statement in C.<br />
<strong>$inputline=&lt;stdin&gt;</strong><br />
Here we are setting a variable named inputline, and storing the input from the keyboard into that variable. &lt;stdin&gt; takes the input from the keyboard.<br />
<strong>print ($inputline);</strong><br />
This line echoes the typed in message.</p>
<h2><strong>Running your first Perl program</strong></h2>
<p>Copy the above above program in to your favorite text editor and save it as <strong>myFirstPerlProgram.pl</strong> and then change it to a executable, you can do that by typing the following in the terminal</p>
<blockquote><p>chmod +x myFirstPerlProgram.pl</p></blockquote>
<p>now you can run this code by typing myFirstPerlProgram.pl in the terminal</p>
<div id="attachment_112" class="wp-caption aligncenter" style="width: 515px"><img class="size-full wp-image-112" title="Running a perl program" src="http://geeksplanet.net/wp-content/uploads/2009/06/perl-program.png" alt="Output of the above perl program" width="505" height="79" /><p class="wp-caption-text">Output of the above perl program</p></div>
]]></content:encoded>
			<wfw:commentRss>http://geeksplanet.net/2009/06/perl/installing-perl-and-writing-your-first-perl-program-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

