<?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>ramraje.com &#187; Perl Basics</title>
	<atom:link href="http://www.ramraje.com/tag/perl-basics/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ramraje.com</link>
	<description>Software Programming Blog</description>
	<lastBuildDate>Fri, 28 May 2010 17:03:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Perl Basics part 2: Scalars, Arrays, and Hashes</title>
		<link>http://www.ramraje.com/programming/perl/perl-basics-part-2-scalars-arrays-and-hashes/</link>
		<comments>http://www.ramraje.com/programming/perl/perl-basics-part-2-scalars-arrays-and-hashes/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 09:32:21 +0000</pubDate>
		<dc:creator>Ramraj Edagutti</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Arrays]]></category>
		<category><![CDATA[Hashes]]></category>
		<category><![CDATA[Perl Basics]]></category>
		<category><![CDATA[Scalars]]></category>

		<guid isPermaLink="false">http://www.ramraje.com/?p=111</guid>
		<description><![CDATA[In this part 2 section of perl basics, we will learn about perl scalars, arrays, and hashes which are heart of the perl language syntax.  In C, Java and C++ programming languages we call varibales which holds or stores data, here in perl we call it scalars.  Scalars are defined with prefixed &#8216;$&#8217; symbols as [...]]]></description>
			<content:encoded><![CDATA[<p>In this part 2 section of perl basics, we will learn about perl scalars, arrays, and hashes which are heart of the perl language syntax.  In C, Java and C++ programming languages we call varibales which holds or stores data, here in perl we call it scalars.  Scalars are defined with prefixed &#8216;$&#8217; symbols as shown below.<span id="more-111"></span></p>
<h3>Scalars: also called variables</h3>
<blockquote><p>$i = 10;<br />
$string = &#8216;Ramraj&#8217;;<br />
$float = 1.005;<br />
print &#8220;Int value is = $i n&#8221;;<br />
print &#8220;String value is = $string n&#8221;;<br />
print &#8220;Float value is = $float n&#8221;;</p></blockquote>
<p>In above code snippet three variables or scalars are defined, and the first one $i  stores integer values, $string stores string value, and $float scalar is floating point value. Perl scalars can hold integers or numbers, string values, and decimal point values such as float, double etc. there is no need to define variable type unlike in java, C, and C++.  Perl is dynamic language and perl interpreter determines types automatically at runtime, this is one big benefit compare to those languages.</p>
<p>In the above code, three print statements prints the all three variables, and &#8216;n&#8217; is new line character to print each line in a new line.</p>
<h3>Arrays: List of scalars</h3>
<p>Arrays are defined with prefixed &#8216;@&#8217;  symbol, which is called at symbol. Arrays store list of elements or scalars and provides mechanism to retrieve the values from the array. Arrays are very important and fundamental data structure for any programming languages.</p>
<p>array syntax:</p>
<blockquote><p>@array = (1, 2, 3, 4, 5);  #list of integer values<br />
@strarray = (&#8216;ram&#8217;, &#8216;raj&#8217;, &#8216;jhon&#8217;, &#8216;mohan&#8217;);  #list of string values<br />
print &#8220;List the integer array: @array n&#8221;<br />
print &#8220;List the string array: @strarray n&#8221;<br />
print &#8220;Print the first value: $array[0]&#8220;</p></blockquote>
<p>Arrays are zero index based list means first values stores at zero index, and next value at 1st index and so on. Above you can see two arrays one with a list of integer values, and another array filled with string values. To print array values use index value with array scalar like $array[0] prints &#8216;1&#8242; , and $array[1] print &#8216;2&#8242;.</p>
<h3>Hashes: also called Dictionaries</h3>
<p>Hashes are prefixed with &#8216;%&#8217; symbol and defines name value pair mappings.</p>
<p>hashes syntax:</p>
<blockquote><p>%ha = (&#8220;Ram&#8221; =&gt; 1, &#8220;Raj&#8221; =&gt; 2, &#8220;Bem&#8221; =&gt; 9, &#8220;hey&#8221; =&gt; 10);</p>
<p>print $ha{&#8220;Ram&#8221;} #prints value &#8216;1&#8242;</p></blockquote>
<p>We have now learned the basic data element structures and syntax in perl. Try yourself all above mentioned code samples and let me know if you have any problem in understanding.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramraje.com/programming/perl/perl-basics-part-2-scalars-arrays-and-hashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl Basics part 1: Every first Perl program</title>
		<link>http://www.ramraje.com/programming/perl/perl-basics-every-first-perl-program/</link>
		<comments>http://www.ramraje.com/programming/perl/perl-basics-every-first-perl-program/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 18:12:13 +0000</pubDate>
		<dc:creator>Ramraj Edagutti</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Perl Basics]]></category>

		<guid isPermaLink="false">http://www.ramraje.com/?p=100</guid>
		<description><![CDATA[Hello, how you doing today? I hope you doing great. I know, you came here to learn some perl basics and write some sample code to get used to it. Okay, lets get in and write our first perl program.
1. Install perl distribution from perl.org, download here
or
you can also downalod perl from activestate.com which comes [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, how you doing today? I hope you doing great. I know, you came here to learn some perl basics and write some sample code to get used to it. Okay, lets get in and write our first perl program.<span id="more-100"></span></p>
<p>1. Install perl distribution from perl.org, <a title="Perl 5.10 download" href="http://www.cpan.org/authors/id/R/RG/RGARCIA/perl-5.10.0.tar.gz">download here</a></p>
<p>or</p>
<p>you can also downalod perl from<a href="http://www.activestate.com" target="_blank"> activestate.com</a> which comes few additional perl modules.</p>
<p>2. To write perl programs you need a text editor or perl IDE. you can use simple notepad or textpad, or you can also perl IDE such as a <a title="Open Perl IDE" href="http://open-perl-ide.sourceforge.net/" target="_blank">Open Perl IDE</a> or <a title="Perl Express download" href="http://www.perl-express.com/download.html" target="_blank">Perl Express</a>. I personally use advance notepad called <a title="Notepad++" href="notepad-plus.sourceforge.net" target="_blank">NotePad++</a>, which is opensource and free software.</p>
<p>3.  Now, create a file called testperl.pl, perls files end with .pl file extension.</p>
<p>4. Write the below statement in the created testperl.pl file</p>
<blockquote><p>print &#8220;Hello World n&#8221;;</p></blockquote>
<p>5. Open the command prompt, and go to the folder where you have a testperl.pl and run the below command</p>
<blockquote><p>perl testperl.pl</p></blockquote>
<p>6. Bravo! now you could see &#8220;Hello World&#8221; on command prompt console.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramraje.com/programming/perl/perl-basics-every-first-perl-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
