<?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>IN MY OPINION &#187; Perl</title>
	<atom:link href="http://blog.gomilko.com/category/perl/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.gomilko.com</link>
	<description>Andrew Gomilko's Blog</description>
	<lastBuildDate>Mon, 14 Jan 2008 08:09:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Moving to Eclipse Europa for J2EE programmer</title>
		<link>http://blog.gomilko.com/2007/07/10/moving-to-eclipse-europa-for-j2ee-programmer</link>
		<comments>http://blog.gomilko.com/2007/07/10/moving-to-eclipse-europa-for-j2ee-programmer#comments</comments>
		<pubDate>Tue, 10 Jul 2007 21:22:26 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.gomilko.com/2007/07/10/moving-to-eclipse-europa-for-j2ee-programmer/</guid>
		<description><![CDATA[Europa release
With a short delay after Europa release announcement, I&#8217;ve moved to it. Thanks to the fact that Eclipse doesn&#8217;t require an installation process and can be just unzipped and run, the last few times I got the tuned Eclipse from my co-workers. Those distributions were well-tuned for J2EE development, with all necessary plugins, project [...]]]></description>
			<content:encoded><![CDATA[<h3>Europa release</h3>
<p>With a short delay after Europa release announcement, I&#8217;ve moved to it. Thanks to the fact that Eclipse doesn&#8217;t require an installation process and can be just unzipped and run, the last few times I got the tuned Eclipse from my co-workers. Those distributions were well-tuned for J2EE development, with all necessary plugins, project <a href="http://checkstyle.sourceforge.net/">checkstyles</a>, attached sources and so on. Seeing as this time nobody around me offered me such a favor, I did everything on my own.<br />
Actually, to develop a J2EE project, you need to install a dozen of plugins (depends on which frameworks are employed) in addition to the bare distribution, so it&#8217;s better to have a cheat sheet every time you start this Eclipse tuning campaign. Since I didn&#8217;t have such a plan, I used my current Eclipse 3.1 working set as an example.<br />
This time, I wrote some short notes during the installation process, and I&#8217;d like to share it here, to have something in the future to stick with.</p>
<h3>Download</h3>
<p>Firstly, you need to download an appropriate Eclipse distribution. However there is already a bundle for J2EE developer, I was interested in installing everything I want from the scratch. Therefore I went to <a href="http://www.eclipse.org/downloads/">http://www.eclipse.org/downloads/</a> and downloaded <strong>Eclipse Classic</strong> distribution for Windows (140 MB). It was extracted to C:\Java\eclipse3.3 directory where I store all Java stuff like IDEs, JDKs, etc. Then, as usually I wanted to create a custom shortcut with extended memory allocation for Eclipse, but suddenly noticed <strong>eclipse.ini</strong> file. To allow Eclipse allocation of more memory, just edit the <strong>eclipse.ini</strong> file (increase Xms and Xmx values):</p>
<div class="dean_ch" style="white-space: wrap;">
-showsplash<br />
org.eclipse.platform<br />
&#8211;launcher.XXMaxPermSize<br />
256m<br />
-vmargs<br />
-Xms256m<br />
-Xmx512m<br />
&nbsp;</div>
<h3>Web tools</h3>
<p><em>Some general notes.</em> All plugins can be installed in two common ways: through cute <strong>Help->Software Updates->Find and Install&#8230;</strong> and copying all unzipped stuff to <strong>ECLIPSE_HOME/plugins</strong> directory. Of course I prefer the first option, and every plugin I&#8217;ll be installing through this wizard, except of Sysdeo.<br />
By &#8220;default plugins&#8221; I mean plugins which can be installed through &#8220;Europa Discovery Site&#8221; (run the mentioned wizard and find it to be accustomed, if not yet).</p>
<p>From the past experience I knew that I was using a <a href="http://www.eclipse.org/webtools">WTP</a> (stands for Web Tools Platform) plugin for web development. The problem was that there were no mentioned WTP plugin on the &#8220;Europa Discovery Site&#8221;. I carried brief investigation and dig out that the main part of that plugin is a <a href="http://www.eclipse.org/webtools/wst/main.php">WST</a> subproject (the web standard tools subproject).<br />
Steps to reproduce after <strong>Help->Software Updates->Find and Install&#8230;</strong>:<br />
<img src="http://gallery.gomilko.com/d/2452-1/WST.png" alt="WST plugin" /><br />
When I checked WST check box, the wizard apparently gave a tip to select all dependent (required by WST) things too. After I installed a WST, the link to WTP update site suddenly appeared (I guess that it was due to WST), and I decided to install it to have a full stack.<br />
<img src="http://gallery.gomilko.com/d/2459-1/WTP.png" alt="WTP plugin" /></p>
<h3>Subversion integration</h3>
<p>When I installed all useful tools from the Europa repository, I moved to things which update sites have to be added manually. The process is almost the same as when we were updating standard components, the only difference is the update site where the plugin is stored. We need to add http://subclipse.tigris.org/update_1.2.x as a <strong>New Remote Site&#8230;</strong><br />
<img src="http://gallery.gomilko.com/d/2457-1/updateManager.png" alt="Update manager" /></p>
<h3>Tomcat launcher</h3>
<p>The simplest and the most valuable plugin for Eclipse invoking I ever used is a <a href="http://www.eclipsetotale.com/tomcatPlugin.html">Sysdeo</a> Tomcat launcher. Download the archive and install according to Installation section steps. Here, the unzipped archive should be placed manually to the <strong>ECLIPSE_HOME/plugins</strong> directory.<br />
<img src="http://gallery.gomilko.com/d/2455-1/sysdeoButtons.png" alt="Sysdeo butons" /></p>
<h3>Useful tools</h3>
<p>As you know how to install plugins, I&#8217;ll mention only links to update site:</p>
<ol>
<li><a href="http://eclipse-cs.sourceforge.net/update">http://eclipse-cs.sourceforge.net/update</a> &#8211; checkstyle plugin, helps to maintain your coding style due to different available code conventions (Sun, Eclipse, your own)
</li>
<li>
<a href="http://springide.org/updatesite/SpringIDE">http://springide.org/updatesite/SpringIDE</a> &#8211; Spring related things like bean definitions, xml configuration auto completion
</li>
<li>
<a href="http://e-p-i-c.sf.net/updates">http://e-p-i-c.sf.net/updates</a> &#8211; Perl IDE, just for fun to play with RegExps or to write some admin tools
</li>
<li>
<a href="http://www.fabioz.com/pydev/updates">http://www.fabioz.com/pydev/updates</a> &#8211; PyDev (Python IDE) not to be restricted only by Java world and be more broadminded
</li>
<li>
<a href="http://eclipse-tools.sourceforge.net/implementors/">http://eclipse-tools.sourceforge.net/implementors/</a> &#8211; nice Alt+F3 short key usage, allows quick jumps to implementation from interfaces.
</li>
</ol>
<p>Stay tuned!<br />
P.S. I know that saying this phrase is almost as popular as mentioning iPhone in the blog post <img src='http://blog.gomilko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gomilko.com/2007/07/10/moving-to-eclipse-europa-for-j2ee-programmer/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Perl for Java Programmer: Generating a country list</title>
		<link>http://blog.gomilko.com/2007/06/20/country-list-sql-generating</link>
		<comments>http://blog.gomilko.com/2007/06/20/country-list-sql-generating#comments</comments>
		<pubDate>Wed, 20 Jun 2007 09:08:35 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Code snippets]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://blog.gomilko.com/2007/06/20/country-list-sql-generating/</guid>
		<description><![CDATA[Introduction
Almost every business application requires a country list as a dictionary data. Even simple registration form might contain country input field. And if you&#8217;re going to store billing or shipping information beyond one country you definitely have to have this important dictionary in your system. Firstly, you should decide which countries will be in your [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Almost every business application requires a country list as a dictionary data. Even simple registration form might contain country input field. And if you&#8217;re going to store billing or shipping information beyond one country you definitely have to have this important dictionary in your system. Firstly, you should decide which countries will be in your list. Depends on your goals it might be short list of the largest countries in the world or full list with all Islands, Territories and even <a href="http://en.wikipedia.org/wiki/Antarctica">Antarctica</a>.  Let&#8217;s review common sources for filling your country list dictionary.</p>
<h2>Existing country lists</h2>
<p>If you have billing or shipping integration with 3rd parties like <a href="http://www.paypal.com">PayPal</a>, you can get this list from the register page html source code. Open a page with the registration information on the any trusted web portal, then find in the source code country list data (e.g. &#8220;View -> Page Source&#8221; in FF):</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="sc3"><span class="re1">&lt;option</span> <span class="re0">value</span>=<span class="st0">&quot;AL&quot;</span><span class="re2">&gt;</span></span>Albania<span class="sc3"><span class="re1">&lt;/option<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;option</span> <span class="re0">value</span>=<span class="st0">&quot;DZ&quot;</span><span class="re2">&gt;</span></span>Algeria<span class="sc3"><span class="re1">&lt;/option<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;option</span> <span class="re0">value</span>=<span class="st0">&quot;AD&quot;</span><span class="re2">&gt;</span></span>Andorra<span class="sc3"><span class="re1">&lt;/option<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;option</span> <span class="re0">value</span>=<span class="st0">&quot;AO&quot;</span><span class="re2">&gt;</span></span>Angola<span class="sc3"><span class="re1">&lt;/option<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;option</span> <span class="re0">value</span>=<span class="st0">&quot;AI&quot;</span><span class="re2">&gt;</span></span>Anguilla<span class="sc3"><span class="re1">&lt;/option<span class="re2">&gt;</span></span></span><br />
&#8230;&#8230;&#8230;<br />
&nbsp;</div>
</ul>
<p>Now you can copy&#038;paste this information and then parse/use it in any convenient way. As you can see, the value in this list is a two character identifier which is called &#8216;<a href="http://en.wikipedia.org/wiki/ISO_3166-1">ISO 3166-1 2 Letter Code</a>&#8216; . It is very useful as a unique identifier and can work as a primary key in the countries DB table.<br />
However there are lot&#8217;s of sites which already have well-proven lists, I&#8217;d suggest take this list directly from the original source &#8211; United Nations published<br />
official list, which is republished in the many places like <a href="http://schmidt.devlib.org/data/countries.html">List of countries and territories</a> or <a href="http://www.addressdoctor.com/en/products/ressources/isocodes.asp">ISO country codes</a>. </p>
<h3>Generating SQL for country table</h3>
<p>Let&#8217;s take one of that list and paste everything to the Excel sheet, then save it in the CSV format. The result should be similar to <a href='http://blog.gomilko.com/wp-content/uploads/2007/05/ISOCodes.csv' title='ISOCodes.csv'>ISOCodes.csv</a> and contains data separated by commas:</p>
<div class="dean_ch" style="white-space: wrap;">
ABW,AW,Aruba<br />
AFG,AF,Afghanistan<br />
AGO,AO,Angola<br />
AIA,AI,Anguilla<br />
ALA,AX,Aland Islands<br />
&#8230;&#8230;&#8230;<br />
&nbsp;</div>
<p>Once we have data stored in Perl readable format, we can parse it and generate SQL code:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="co1">#!/usr/bin/perl</span></p>
<p><span class="co1"># PERL MODULE</span><br />
<span class="kw2">use</span> Text::<span class="me2">CSV</span>::<span class="me2">Simple</span>;<br />
&nbsp; &nbsp; <br />
<span class="co1"># This script generetes sql code for country table</span></p>
<p><a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> &lt;&lt;SQL_END;<br />
DROP TABLE IF EXISTS country;<br />
CREATE TABLE country <span class="br0">&#40;</span><br />
&nbsp; short_code varchar<span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span> NOT NULL COMMENT <span class="st0">&#8216;ISO 3166-1 2 Letter Code&#8217;</span>,<br />
&nbsp; name varchar<span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> NOT NULL,<br />
&nbsp; PRIMARY KEY &nbsp;<span class="br0">&#40;</span>short_code<span class="br0">&#41;</span>,<br />
&nbsp; UNIQUE KEY UNQ_COUNTRY_NAME <span class="br0">&#40;</span>name<span class="br0">&#41;</span><br />
<span class="br0">&#41;</span> ENGINE=InnoDB DEFAULT CHARSET=utf8;<br />
SQL_END</p>
<p><span class="kw1">my</span> <span class="re0">$tplSQL</span> = <span class="st0">&quot;INSERT INTO country (short_code, name) VALUES (<span class="es0">\&quot;</span>%s<span class="es0">\&quot;</span>,<span class="es0">\&quot;</span>%s<span class="es0">\&quot;</span>);<span class="es0">\n</span>&quot;</span>;<br />
<span class="kw1">my</span> <span class="re0">$tplXML</span> = <span class="st0">&quot;&lt;country short_code=<span class="es0">\&quot;</span>%s<span class="es0">\&quot;</span> name=<span class="es0">\&quot;</span>%s<span class="es0">\&quot;</span> /&gt;<span class="es0">\n</span>&quot;</span>;<br />
<span class="kw1">my</span> <span class="re0">$csvFile</span>=<span class="st0">&quot;H:/workspace/update/data/ISOCodes.csv&quot;</span>;</p>
<p><span class="kw1">my</span> <span class="re0">$parser</span> = Text::<span class="me2">CSV</span>::<span class="me2">Simple</span>-&gt;<span class="me1">new</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">my</span> <span class="re0">@data</span> = <span class="re0">$parser</span>-&gt;<span class="me1">read_file</span><span class="br0">&#40;</span><span class="re0">$csvFile</span><span class="br0">&#41;</span>;</p>
<p><a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;&#8211; SQL DUMP<span class="es0">\n</span>&quot;</span>;<br />
<span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">@data</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/printf.html"><span class="kw3">printf</span></a> <span class="re0">$tplSQL</span>, <span class="re0">@$_</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>, <span class="re0">@$_</span><span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span>;<br />
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;&#8211; Data for DBUnit tests<span class="es0">\n</span>&quot;</span>;<br />
<span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">@data</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/printf.html"><span class="kw3">printf</span></a> <span class="re0">$tplXML</span>, <span class="re0">@$_</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>, <span class="re0">@$_</span><span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span>;<br />
&nbsp;</div>
<p>I&#8217;d prefer not to populate data directly to DB, but generate a script which can be edited and invoked many times. This script doesn&#8217;t work with command line parameters and use hard coded path because I&#8217;m not a Perl programmer who develops a multi-purpose tool:) I&#8217;m just a Java developer who needed a valid country list. After executing this script you&#8217;ll get <a href="http://blog.gomilko.com/wp-content/uploads/2007/05/country.sql">SQL code</a> and DBUnit xml snippets. </p>
<h3>For those who are curious</h3>
<p>Unfortunately, there are no one common countries list, however there are some official lists supported by different organizations like UN, bank communities, post offices, phone companies. When you&#8217;re choosing a proper list, take in account countries which are disappeared like USSR or was divided like Serbia and Montenegro. Choose a primary key from large variety of existent (ISO 2,3 characters, number, phone code,&#8230;)  which satisfies your needs. If you have a unique key, you can get another useful information about chosen country from other sources afterwards. To get answers on those questions, I&#8217;d recommend to skim through <a href="http://www.madore.org/~david/misc/countries.html">How many countries are there in the world?</a> and then google on interested keywords.</p>
<p>This is a part of Perl for Java Programmer series. Previous post was <a href="http://blog.gomilko.com/2007/06/18/perl-for-java-installation/">Perl for Java programmer: Installation</a>. Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gomilko.com/2007/06/20/country-list-sql-generating/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl for Java programmer: Installation</title>
		<link>http://blog.gomilko.com/2007/06/18/perl-for-java-installation</link>
		<comments>http://blog.gomilko.com/2007/06/18/perl-for-java-installation#comments</comments>
		<pubDate>Mon, 18 Jun 2007 19:42:47 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://blog.gomilko.com/2007/06/18/perl-for-java-installation/</guid>
		<description><![CDATA[Introduction
Let&#8217;s assume that you are a Java server side programmer. Your current web project involves working with server side specific data, such as lots of media files which are stored in file storages, DB data, XML files, configuration files etc. All files are stored under proper sub-directories, your objects are beautifully mapped to DB using [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Let&#8217;s assume that you are a Java server side programmer. Your current web project involves working with server side specific data, such as lots of media files which are stored in file storages, DB data, XML files, configuration files etc. All files are stored under proper sub-directories, your objects are beautifully mapped to DB using your preferable ORM like <a href="http://www.hibernate.org/">Hibernate</a>. Another bunch of data is serialized to XML using something like <a href="http://xstream.codehaus.org/">xstream</a>. Everything works like a charm, until the data storage format or convention is changed. For example, you decide to move all your pictures to another sub-folder. If you have references to these files in your DB you have to modify it too. Or, let&#8217;s say, in the next release of your product the textual data stored in the XMLs have to be updated to conform new POJOs which has new properties. What I&#8217;m trying to say here, is that if you develop an application which works with lots of non homogeneous data, you have to have an approach to migrate it from one version to another.<br />
I think, that the best solution is using a script language which supports string parsing, SQL executing, file I/O. I chose Perl because of it well-known excellent work with regexps and good reputation between system administrators. </p>
<h2>Installing/Configuring Perl</h2>
<p>If you are a lucky user of the *nix OS, I believe, you don&#8217;t need any additional installation of the Perl, because it is already included in your distributive. For folks who are using Windows, I would recommend installing <a href="http://www.activestate.com/products/activeperl/">ActivePerl</a> &#8211; Perl binary distribution for Win32 platform. Basically, I don&#8217;t know any other, and this one seems to be the best. Installing is a well-known &#8220;Next-Next-Next&#8221; joy.<br />
My current IDE for Java is <a href="http://www.eclipse.org/">Eclipse</a>. And one of great advantages of this famous IDE is it plugin system. There are lots <a href="http://www.eclipseplugincentral.com/">plugins</a> developed by different people almost for every purpose. The first plugin I found was <a href="http://e-p-i-c.sourceforge.net/">EPIC</a> &#8211; open source Perl IDE. Using this plugin you obtain simple but powerful facilities for Perl programming. It is a code highlighting and intellisense while typing, running a program by clicking right mouse-click on a perl source code file and choosing &#8220;Run as perl&#8221;. Output of the program is directed to Eclipse console. And of course, you can debug the program if output is helpless.<br />
Finally, I&#8217;d like to emphasize the very useful tool which is supplied with ActivePerl  &#8211; <em>Perl Package Manager</em>. Once you need any additional Perl package, you can easily install it in your system from the global repository. <a href="http://blog.gomilko.com/wp-content/uploads/2007/04/perlpackagemanager.jpg" title="Perl Package Manager"><img src="http://blog.gomilko.com/wp-content/uploads/2007/04/perlpackagemanager.jpg" alt="Perl Package Manager" /></a><br />
For instance, you write a simple script which use B connection to a MySQL instance. But there is an error:</p>
<pre>
install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
</pre>
<p>The only thing you have to do, is to open <em>Perl Package Manager</em>, find missed in standard configuration package <em>DBD::mysql</em>, and install it.</p>
<h2>Roadmap of this guide</h2>
<p>Today I decided that writing less but more frequently is easier and using his approach I don&#8217;t need keeping this important post still in drafts. I&#8217;d rather ship every day part by part than wait for another month to complete it.<br />
Therefore, I&#8217;m planning to cover in the near weeks these topics:</p>
<ul>
<li>String manipulation</li>
<li>Files manipulation</li>
<li>DB work</li>
<li>XML work</li>
<li>SQL generating</li>
</ul>
<p>Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gomilko.com/2007/06/18/perl-for-java-installation/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
