<?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; Programming</title>
	<atom:link href="http://www.ramraje.com/ramraj/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ramraje.com</link>
	<description>Software Programming Blog</description>
	<lastBuildDate>Mon, 19 Dec 2011 08:56:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Solution for Python smtplib.SMTPServerDisconnected error</title>
		<link>http://www.ramraje.com/programming/python/how-i-solved-python-smtplibsmtpserverdisconnected/</link>
		<comments>http://www.ramraje.com/programming/python/how-i-solved-python-smtplibsmtpserverdisconnected/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 10:42:04 +0000</pubDate>
		<dc:creator>Ramraj Edagutti</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[smtplib]]></category>
		<category><![CDATA[SMTPServerDisconnected]]></category>

		<guid isPermaLink="false">http://www.ramraje.com/?p=154</guid>
		<description><![CDATA[Since from two  months I have been working on  developing python application to automate the web importer task for our web application, and after completing import job an email needs to  be sent to support team with the importer status.<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/python/how-i-solved-python-smtplibsmtpserverdisconnected/' addthis:title='Solution for Python smtplib.SMTPServerDisconnected error '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Since from two  months I have been working on  developing python application to automate the web importer task for our web application, and after completing import job an email needs to  be sent to support team with the importer status.<span id="more-154"></span></p>
<p>So, while sending email using python smtplib library, I was getting smtplib.SMTPServerDisconnected error. It was working absolutely well before, I was wondering why the SMTPServerDisconnected error was coming now&#8230;</p>
<p>Error log</p>
<div class="geshi no python">
<div class="head">Traceback (most recent call last):</div>
<ol>
<li class="li1">
<div class="de1">File <span class="st0">&quot;ImporterAutomation.py&quot;</span>, line <span class="nu0">470</span>, <span class="kw1">in</span> <span class="sy0">&amp;</span>lt<span class="sy0">;</span>module<span class="sy0">&amp;</span>gt<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">sys</span>.<span class="me1">exit</span><span class="br0">&#40;</span>main<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">File <span class="st0">&quot;ImporterAutomation.py&quot;</span>, line <span class="nu0">462</span>, <span class="kw1">in</span> main</div>
</li>
<li class="li1">
<div class="de1">sendmail.<span class="me1">sendEmail</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">File <span class="st0">&quot;C:projects&#8230;sendmail.py&quot;</span>, line <span class="nu0">83</span>, <span class="kw1">in</span> sendEmail</div>
</li>
<li class="li1">
<div class="de1">emailNotify<span class="br0">&#40;</span>TEXT,Flag<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">File <span class="st0">&quot;C:projects&#8230;.sendmail.py&quot;</span>, line <span class="nu0">101</span>, <span class="kw1">in</span> emailNotify</div>
</li>
<li class="li1">
<div class="de1">server.<span class="me1">sendmail</span><span class="br0">&#40;</span>author, recipient_list, msg.<span class="me1">as_string</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">File <span class="st0">&quot;C:Python26libsmtplib.py&quot;</span>, line <span class="nu0">685</span>, <span class="kw1">in</span> sendmail</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">self</span>.<span class="me1">ehlo_or_helo_if_needed</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">File <span class="st0">&quot;C:Python26libsmtplib.py&quot;</span>, line <span class="nu0">509</span>, <span class="kw1">in</span> ehlo_or_helo_if_needed</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="kw1">not</span> <span class="br0">&#40;</span><span class="nu0">200</span> <span class="sy0">&amp;</span>lt<span class="sy0">;</span>= <span class="kw2">self</span>.<span class="me1">ehlo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> <span class="sy0">&amp;</span>lt<span class="sy0">;</span>= <span class="nu0">299</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">File <span class="st0">&quot;C:Python26libsmtplib.py&quot;</span>, line <span class="nu0">382</span>, <span class="kw1">in</span> ehlo</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">self</span>.<span class="me1">putcmd</span><span class="br0">&#40;</span><span class="kw2">self</span>.<span class="me1">ehlo_msg</span>, name <span class="kw1">or</span> <span class="kw2">self</span>.<span class="me1">local_hostname</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">File <span class="st0">&quot;C:Python26libsmtplib.py&quot;</span>, line <span class="nu0">318</span>, <span class="kw1">in</span> putcmd</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">self</span>.<span class="me1">send</span><span class="br0">&#40;</span><span class="kw2">str</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">File <span class="st0">&quot;C:Python26libsmtplib.py&quot;</span>, line <span class="nu0">310</span>, <span class="kw1">in</span> send</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">raise</span> SMTPServerDisconnected<span class="br0">&#40;</span><span class="st0">&#39;please run connect() first&#39;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">smtplib</span>.<span class="me1">SMTPServerDisconnected</span>: please run connect<span class="br0">&#40;</span><span class="br0">&#41;</span> first</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">Then after some <span class="kw3">time</span> I figured out it was problem with configuring SMTP host ip address. <span class="me1">There</span> was no smtp host configured <span class="kw1">in</span> configuration <span class="kw2">file</span>.</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span>blockquote<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">smtp = <span class="kw3">smtplib</span>.<span class="me1">SMTP</span><span class="br0">&#40;</span>smtp_host<span class="br0">&#41;</span> &#8212; here smtp_host was null<span class="sy0">&lt;</span>/blockquote<span class="sy0">&gt;</span></div>
</li>
</ol>
</div>
<p>Above smtp instance variable is created without SMTP connection, so when I was calling smtp.sendmail() method python smtp lib was throwing that error.</p>
<p>To fix it,  I provided correct SMTP host/ip address, and also added error handling code to gracefully handle that error condition and log error message in log file.</p>
<p>Below is the fix</p>
<div class="geshi no python">
<div class="head">try:</div>
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; smtp = <span class="kw3">smtplib</span>.<span class="me1">SMTP</span><span class="br0">&#40;</span>smtp_host<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> smtp_username <span class="kw1">and</span> smtp_password:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;smtp .<span class="me1">login</span><span class="br0">&#40;</span>smtp_username, smtp_password<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; smtp .<span class="me1">sendmail</span><span class="br0">&#40;</span>author, recipient_list, msg.<span class="me1">as_string</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">except</span> <span class="kw3">smtplib</span>.<span class="me1">SMTPException</span>, e:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; err_log.<span class="me1">error</span><span class="br0">&#40;</span><span class="st0">&#39;Error while seding email summary&#8230;.&#39;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; err_log.<span class="me1">error</span><span class="br0">&#40;</span>e<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">except</span> <span class="kw3">socket</span>.<span class="me1">error</span>, e:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; err_log.<span class="me1">error</span><span class="br0">&#40;</span><span class="st0">&#39;Unable to connect to SMTP server&#8230;.&#39;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; err_log.<span class="me1">error</span><span class="br0">&#40;</span>e<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">else</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; smtp .<span class="me1">quit</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>I know this very basic part of python smtp module, hope this may help python freshers. Any comments or feedback are welcome.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/python/how-i-solved-python-smtplibsmtpserverdisconnected/' addthis:title='Solution for Python smtplib.SMTPServerDisconnected error '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.ramraje.com/programming/python/how-i-solved-python-smtplibsmtpserverdisconnected/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Popular Perl web applications, part 1</title>
		<link>http://www.ramraje.com/programming/perl/popular-perl-web-applications-part-1/</link>
		<comments>http://www.ramraje.com/programming/perl/popular-perl-web-applications-part-1/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 16:24:04 +0000</pubDate>
		<dc:creator>Ramraj Edagutti</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[BugZilla]]></category>
		<category><![CDATA[IMDb.com]]></category>
		<category><![CDATA[Internet Movie Database]]></category>
		<category><![CDATA[Movable Type]]></category>
		<category><![CDATA[Perl applications]]></category>
		<category><![CDATA[Perl Web Applications]]></category>

		<guid isPermaLink="false">http://www.ramraje.com/?p=127</guid>
		<description><![CDATA[Movable Type Movable Type is premium publishing and blogging software which is developed using perl.It is used for developing blog websites, content managed websites along with  social communities. Latest version of Movable Type runs on perl 5.8.1 or above. Unlike wordpress, another popular open source blogging software, movable type supports both static and dynaminc content [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/popular-perl-web-applications-part-1/' addthis:title='Popular Perl web applications, part 1 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<h3>Movable Type</h3>
<p>Movable Type is premium publishing and blogging software which is developed using perl.It is used for developing blog websites, content managed websites along with  social communities. Latest version of Movable Type runs on perl 5.8.1 or above.<span id="more-127"></span></p>
<p>Unlike wordpress, another popular open source blogging software, movable type supports both static and dynaminc content publishing, but dynamic publishing requires PHP4 or PHP5. And also Movable type does not support mod_perl with Apache web server version 2.x. Movable Type is available under both open source and commercial licenses.</p>
<h3>Internet Movie Database (IMDb.com)</h3>
<p>Full form of IMDb is &#8220;Internet Movie Database&#8221;. IMDb.com websites is a huge collection of movies, tv and video shows. Till date it has collected over 15 million movie/tv shows information. This site has a more than 57 million monthly visitors with 17 million registered users. And no wonder this great website been developed using perl, apart from perl they also uses java and python programming languages.</p>
<h3>BugZilla</h3>
<p>BugZilla is a software bug tracking system. This projects mainly uses mod_perl and DBD::mysql modules for development. Major software companies across the globe uses this tool to track the software defects/bugs and effectively manage their projects.</p>
<p>It is a open source and free solution avaible to any one at no charge. Bugzilla also provides additional  features like tracking code changes, submitting patches and effecive communication among team members.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/popular-perl-web-applications-part-1/' addthis:title='Popular Perl web applications, part 1 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.ramraje.com/programming/perl/popular-perl-web-applications-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introduction to Perl CGI web developemnt</title>
		<link>http://www.ramraje.com/programming/perl/introduction-to-perl-cgi-web-developemnt/</link>
		<comments>http://www.ramraje.com/programming/perl/introduction-to-perl-cgi-web-developemnt/#comments</comments>
		<pubDate>Fri, 15 May 2009 18:23:03 +0000</pubDate>
		<dc:creator>Ramraj Edagutti</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[CGI]]></category>
		<category><![CDATA[CGI web development]]></category>
		<category><![CDATA[Perl CGI]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://www.ramraje.com/?p=124</guid>
		<description><![CDATA[Common Gateway Interface The Common Gateway Interface(CGI) is a standard protocol for web communication between HTTP server or web server and a CGI sciprts/programs. In other terms, CGI is specification for data transmission between web server and CGI programs. Basically, web servers are the one who implements the CGI specifications. The main job of the [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/introduction-to-perl-cgi-web-developemnt/' addthis:title='Introduction to Perl CGI web developemnt '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<h3>Common Gateway Interface</h3>
<p>The Common Gateway Interface(CGI) is a standard protocol for web communication between HTTP server or web server and a CGI sciprts/programs. In other terms, CGI is specification for data transmission between web server and CGI programs. Basically, web servers are the one who implements the CGI specifications.<span id="more-124"></span></p>
<p>The main job of the web server(also called HTTP server) is to take the user request from browser and execute specific CGI programs which resides in the web server and generate the output and then send it back to the browser for display. In between, browser is a client side program which knows how to talk to web server and get back the respose to display to the end user. Internet Explorer, Mozilla firefox, Opera, Apple&#8217;s safari and Google chrome are the most popular web browsers used in the world.</p>
<p>CGI programs can be implemented in any programming language such as C, C++, perl, and python etc. Among all these Perl is the most popular choice for CGI web development.</p>
<h3>Common uses of Perl CGI programming</h3>
<ul>
<li>To process the HTML forms</li>
<li>To provide dynamic website feedback</li>
<li>To generate dynamic web pages</li>
<li>To develop large and enterprise/business web applications</li>
</ul>
<p>There is one problem with CGI scripts that every time web server receive a request for CGI script it spawns a new process to execute the script. This puts lots of load on web server specially for website which has millions of page views. Due to this reason java servlets are superseded the CGI programming in web development.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/introduction-to-perl-cgi-web-developemnt/' addthis:title='Introduction to Perl CGI web developemnt '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.ramraje.com/programming/perl/introduction-to-perl-cgi-web-developemnt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl basics part 3: Control Statements</title>
		<link>http://www.ramraje.com/programming/perl/perl-basics-part-3-control-statements/</link>
		<comments>http://www.ramraje.com/programming/perl/perl-basics-part-3-control-statements/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 11:06:22 +0000</pubDate>
		<dc:creator>Ramraj Edagutti</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Perl Conditional Statements]]></category>
		<category><![CDATA[Perl conditions]]></category>
		<category><![CDATA[Perl If]]></category>

		<guid isPermaLink="false">http://www.ramraje.com/?p=114</guid>
		<description><![CDATA[In this part of perl basics, we will going to learn about perl control statements such as if, elseif, and else statements etc. If, elseif, and else statements are conditional statements and are executed only if certain condition met. If Conditional Statements If statement syntax $i = 10; if ($i == 5){ if statements here.. [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/perl-basics-part-3-control-statements/' addthis:title='Perl basics part 3: Control Statements '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>In this part of perl basics, we will going to learn about perl control statements such as if, elseif, and else statements etc. If, elseif, and else statements are conditional statements and are executed only if certain condition met.<span id="more-114"></span></p>
<h3>If Conditional Statements</h3>
<p>If statement syntax</p>
<blockquote><p>$i = 10;</p>
<p>if ($i == 5){</p>
<p>if statements here..</p>
<p>} elseif ($i == 10){</p>
<p>elseif statements here..</p>
<p>} else {</p>
<p>else statements here..</p>
<p>}</p></blockquote>
<p>In the above code snippet, elseif condition evaluates to true so statements under elseif block will get executed.</p>
<h3>Unless Conditional Statements</h3>
<p>Unless conditional statements are right opposite to if conditions. Unless conditional statements get executed only when certain condition evaluates to false, where as if statements are executed on true condition. And also unless can have else block just like if statements.</p>
<p>Unless syntax</p>
<blockquote><p>unless (conditional_statement){</p>
<p>unless_statements_here;</p>
<p>} else {</p>
<p>else_statements_here;</p>
<p>}</p></blockquote>
<h3>Switch Statements</h3>
<p>Switch statements are not built in perl core modules, you need to import switch module to use it. This is basically used for value-case match, where we have a switch scalar and different case statements and when switch scalar values matches to any of the case value then that particular case statements will get executed.</p>
<p>Switch statement</p>
<blockquote><p>switch ($scalar_value) {</p>
<p>case [$case_value] { statements here..}</p>
<p>case[$case_value] { statements here.. }</p>
<p>else { else_statements here..}</p>
<p>}</p></blockquote>
<p>When any case value matches with switch $scalar_value then that particular case statements are executed.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/perl-basics-part-3-control-statements/' addthis:title='Perl basics part 3: Control Statements '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.ramraje.com/programming/perl/perl-basics-part-3-control-statements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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 [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/perl-basics-part-2-scalars-arrays-and-hashes/' addthis:title='Perl Basics part 2: Scalars, Arrays, and Hashes '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></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 &#8217;1&#8242; , and $array[1] print &#8217;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 &#8217;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>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/perl-basics-part-2-scalars-arrays-and-hashes/' addthis:title='Perl Basics part 2: Scalars, Arrays, and Hashes '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></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 [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/perl-basics-every-first-perl-program/' addthis:title='Perl Basics part 1: Every first Perl program '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></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>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/perl-basics-every-first-perl-program/' addthis:title='Perl Basics part 1: Every first Perl program '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></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>
		<item>
		<title>Perl Programming language history</title>
		<link>http://www.ramraje.com/programming/perl/perl-programming-language-history/</link>
		<comments>http://www.ramraje.com/programming/perl/perl-programming-language-history/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 18:05:45 +0000</pubDate>
		<dc:creator>Ramraj Edagutti</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Perl history]]></category>
		<category><![CDATA[Perl Programming]]></category>

		<guid isPermaLink="false">http://www.ramraje.com/?p=92</guid>
		<description><![CDATA[I was originally written this article for giving presentation to my team mates in 2007. And thought of putting part of it here in my blog. Below are the few facts and features of  this very old programming language. Perl history and Facts Perl was initially developed by Larry Wall in 1987. Perl is a [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/perl-programming-language-history/' addthis:title='Perl Programming language history '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>I was originally written this article for giving presentation to my team mates in 2007. And thought of putting part of it here in my blog. Below are the few facts and features of  this very old programming language.<span id="more-92"></span></p>
<h2>Perl history and Facts</h2>
<ul>
<li><a title="Perl Official webpage" href="http://www.perl.org" target="_blank">Perl</a> was initially developed by Larry Wall in 1987.</li>
<li>Perl is a open source software licensed under <a title="GNU public license" href="http://dev.perl.org/licenses/gpl1.html" target="_blank">GNU public license </a></li>
<li>It was made as a unix scripting language for reporting process.</li>
<li>Perl is also called as the swiss army chainsaw of programming languages due to its flexible and adaptable nature.</li>
<li>Perl  2 released in 1988 with better and improved regular exprssion engine</li>
<li>In 1989, perl 3 was released with added feature of handling binary data streams.</li>
<li>In 1991, perl reference documentations has been published, it is also called as &#8216;Camel Book&#8217; and version was renamed to Perl 4.</li>
<li>Perl interpreter was completely rewritten and released in 1994 as Perl verison 5.</li>
<li>Perl 5.x version is the most widely used as of now</li>
</ul>
<h2>Perl Features</h2>
<ul>
<li>Perl is a interpreted and dynamic programming language</li>
<li>Perl is stable and cross-platform programming language.</li>
<li>It has inherited the best features from C, Basic and other programming languages.</li>
<li>Perl supports Unicode character encoding for foreign letters.</li>
<li>Other interesting feature is, it supports both procedural and object oriented programming.</li>
<li>Perl is extensible and can be integrated with C and C++.</li>
<li>Perl is best known for powerful text processing engine.</li>
<li>And perl was known to be the most popular web programming language until PHP supercedes it.</li>
</ul>
<p>Probably in my next perl article, I will talk about perl programming basics with few sample code.</p>
<p>Don&#8217;t forget to say what do you think about perl, find comment section below to post your comments.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.ramraje.com/programming/perl/perl-programming-language-history/' addthis:title='Perl Programming language history '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.ramraje.com/programming/perl/perl-programming-language-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

