<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Matching Patterns</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/" />
    <link rel="self" type="application/atom+xml" href="http://www.haboogo.com/matching_patterns/atom.xml" />
    <id>tag:www.haboogo.com,2009-01-03:/matching_patterns//1</id>
    <updated>2011-07-14T15:48:42Z</updated>
    <subtitle>Confessions of a regex addict</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.23-en</generator>

<entry>
    <title>FreezePanes for Desperados</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2010/03/freezepanes-for-desperadoes.html" />
    <id>tag:www.haboogo.com,2010:/matching_patterns//1.21</id>

    <published>2010-03-28T17:30:00Z</published>
    <updated>2011-07-14T15:48:42Z</updated>

    <summary>UPDATE: Spreadsheet::WriteExcelXML is now deprecated in favor of Excel::Writer::XLSX, which contains a freeze_panes() method since v0.10 (February 17, 2011). So there I was, working on a program that generates an Excel report. Whenever I have to write a program that...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[<font color="red"><b>UPDATE:</b></font> 
Spreadsheet::WriteExcelXML is now deprecated in favor of Excel::Writer::XLSX, which contains a freeze_panes() method since v0.10 (February 17, 2011).
<p>
<p>
<p>
So there I was, working on a program that generates an Excel report.
Whenever I have to write a program that interfaces with Excel (or, more generally, when I need COM automation), I work with <a href="http://search.cpan.org/~jdb/Win32-OLE/">Win32::OLE</a>, and I have quite a deal of experience doing so. However, I have always found VBA's object model too counterintuitive and often find myself trying things based on hunches rather than common sense; the combination of Excel's macro recorder and ActiveState's <a href="http://docs.activestate.com/pdk/8.2/VBSPerl_gui.html#vbsperl_gui_top">VBScript Converter</a> helps to ease the pain, but... Anyway, I didn't want to rely on a local Excel installation to get the job done.
On the other hand, I wanted to take a multiplatform approach this time, so I decided to try <a href="http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel">Spreadsheet::WriteExcel</a>. This module works fine and has an impressive documentation, chock-full of examples (screenshots and all!), but I got stuck when I tried to find a way of adding several different formatting features to the cells' content  (say, words in different colors).  I contacted the module's author, who replied quickly and informed me that this feature was not supported for technical reasons, but suggested that I could use a related module,  <a href="http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcelXML">Spreadsheet::WriteExcelXML</a>, which provides the convenient <B>write_html_string</B> function for this purpose.
The idea of generating XML output instead of the typical binary format seemed sexy enough, so I adapted the code to the new module.
<p>
<p>
But then I found another problem. I wanted to freeze the headers row and the <B>freeze_panes()</B> method didn't seem to work as it worked with Spreadsheet::WriteExcel. I read again the documentation and found out to my dismay that it's not yet supported in the XML version (although it will eventually be implemented).
I could try to implement it myself, but I don't know well enough this XML vocabulary and it would take me far more time than I can afford right now. So I created a poor man's freeze panes functionality --I always wanted to create a <I>poor man's</I> version of something (just for the sake of using that buzzword); actually, I have done it many times, but never on purpose. So, here is the procedure I followed: I froze panes manually on a sample report open in Excel, and saved it. Then I compared the new file and the original one to get the lines added, and modified my code to insert that patch in a second pass into every automatically generated report:
<p>
<p>
<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$patch</font>&nbsp;= <font color="#4a6f8b">&lt;&lt;'END'</font><font color="#4a6f8b">;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&lt;WorksheetOptions xmlns=&quot;urn:schemas-microsoft-com:office:excel&quot;&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Selected/&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;FreezePanes/&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;FrozenNoSplit/&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;SplitHorizontal&gt;1&lt;/SplitHorizontal&gt;</font><br>

<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;TopRowBottomPane&gt;1&lt;/TopRowBottomPane&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ActivePane&gt;2&lt;/ActivePane&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Panes&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Pane&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Number&gt;3&lt;/Number&gt;</font><br>

<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Pane&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Pane&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Number&gt;2&lt;/Number&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ActiveRow&gt;2&lt;/ActiveRow&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Pane&gt;</font><br>

<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/Panes&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ProtectObjects&gt;False&lt;/ProtectObjects&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ProtectScenarios&gt;False&lt;/ProtectScenarios&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&lt;/WorksheetOptions&gt;</font><br>
<font color="#4a6f8b">&nbsp;&nbsp;&nbsp;&nbsp;&lt;x:FreezePanes x:Range=&quot;A2&quot;&gt;&nbsp;&nbsp; &lt;/x:FreezePanes&gt;&nbsp;&nbsp;&nbsp;&nbsp;</font><br>

<font color="#4a6f8b">END</font><br>
<br>
<font color="#b02f60"><b>open</b></font>&nbsp;<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$in</font>, <font color="#4a6f8b">'</font><font color="#4a6f8b">&lt;:encoding(UTF-8)</font><font color="#4a6f8b">'</font>, <font color="#458b73">$log_path</font>;<br>
<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$text</font>&nbsp;= <font color="#b02f60"><b>do</b></font>&nbsp;{ <font color="#b02f60"><b>local</b></font>&nbsp;<font color="#458b73">$/</font>; &lt;<font color="#458b73">$in</font>&gt; };<br>

<font color="#b02f60"><b>close</b></font>&nbsp;<font color="#458b73">$in</font>;<br>
<br>
<font color="#b02f60"><b>chop</b></font>(<font color="#458b73">$patch</font>);<br>
<font color="#458b73">$text</font>&nbsp;=~ <font color="#b02f60"><b>s/</b></font><font color="#4a6f8b">&lt;</font><font color="#8a2ae2">\/</font><font color="#4a6f8b">Table&gt;</font><font color="#b02f60"><b>/</b></font><font color="#4a6f8b">&lt;</font><font color="#8a2ae2">\/</font><font color="#4a6f8b">Table&gt;</font><font color="#8a2ae2">\n</font><font color="#458b73">$patch</font><font color="#b02f60"><b>/</b></font>;<br>

<br>
<font color="#b02f60"><b>open</b></font>&nbsp;<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$out</font>, <font color="#4a6f8b">'</font><font color="#4a6f8b">&gt;:encoding(UTF-8)</font><font color="#4a6f8b">'</font>, <font color="#458b73">$log_path</font>;<br>
<font color="#b02f60"><b>print</b></font>&nbsp;<font color="#458b73">$out</font>&nbsp;<font color="#458b73">$text</font>;<br>

<font color="#b02f60"><b>close</b></font>&nbsp;<font color="#458b73">$out</font>;<br>
<br>
<p>
Yes, it's a dirty trick, but it works!

]]>
        
    </content>
</entry>

<entry>
    <title>Displaying non-Latin1 Unicode Characters in CPAN Documentation</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2010/02/displaying-non-latin1-unicode-characters-in-cpan-documentation.html" />
    <id>tag:www.haboogo.com,2010:/matching_patterns//1.20</id>

    <published>2010-02-18T19:00:00Z</published>
    <updated>2010-03-27T09:55:02Z</updated>

    <summary><![CDATA[The latest update of the documentation of one of my CPAN modules, String::CaseProfile,&nbsp;includes sample text in alphabets other than the&nbsp;Roman alphabet (namely, Armenian, Greek, and Cyrillic). So I had to convert the encoding to UTF-8 and add the use utf8...]]></summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
        <category term="CPAN" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[<p>The latest update of the documentation of one of my CPAN modules, <a href="http://search.cpan.org/dist/String-CaseProfile/">String::CaseProfile</a>,&nbsp;includes sample text in alphabets other than the&nbsp;Roman alphabet (namely, Armenian, Greek, and Cyrillic).</p>
<p>So I had to convert the encoding to UTF-8 and add the <strong>use utf8</strong> pragma, but while checking the doc of several CPAN modules containing non-Latin1 Unicode characters, I noticed that for many of them, these characters were not displayed correctly. I wanted to make sure that everything was OK before the release, so I asked Joaquín Ferrero, a walking encyclopedia of Perl and administrator of the <a href="http://perlenespanol.com/foro/">Spanish Perl Forum</a>&nbsp;(sort of PerlMonks for the Spanish-speaking community), and he spoke with the wisdom&nbsp;that can only come from experience: Adding the <strong>use utf8</strong> pragma is not enough. You also have to add the following line at the beginning of the Pod text:</p>
<p><strong>=encoding utf8</strong></p>
<p>This way, CPAN's Pod processor knows what is the encoding used in the module and transforms accordingly these Unicode characters into the corresponding HTML entities that will be displayed correctly with the ISO-8859-1 encoding used by default for CPAN documentation in HTML format.</p>
<p>When you think about it, it's quite logical, but the fact is that there are many CPAN modules that don't get this right.</p>
<p>&nbsp;</p>]]>
        
    </content>
</entry>

<entry>
    <title>Installing X11::GUITest on Ubuntu Linux</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2009/09/installing-x11guitest-on-ubuntu-linux.html" />
    <id>tag:www.haboogo.com,2009:/matching_patterns//1.16</id>

    <published>2009-09-29T17:52:48Z</published>
    <updated>2009-09-29T17:52:53Z</updated>

    <summary><![CDATA[When you try to install X11::GUITest on&nbsp;a fresh installation of Ubuntu Linux, you will get the following error: GUITest.xs:41:27: error: X11/Intrinsic.h: No such file or directory GUITest.xs:42:28: error: X11/StringDefs.h: No such file or directory make: *** [GUITest.o] Error 1 &nbsp;...]]></summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[<p>When you try to install <a href="http://search.cpan.org/dist/X11-GUITest">X11::GUITest</a> on&nbsp;a fresh installation of Ubuntu Linux, you will get the following error:</p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText"><font color="#000000" size="3" face="Consolas">GUITest.xs:41:27: error: X11/Intrinsic.h: No such file or directory</font></p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText"><font color="#000000" size="3" face="Consolas">GUITest.xs:42:28: error: X11/StringDefs.h: No such file or directory</font></p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText"><font color="#000000" size="3" face="Consolas">make: *** [GUITest.o] Error 1</font></p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText">&nbsp;</p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText">To fix it, you must install first the X.Org X Window System development libraries:&nbsp;</p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText">&nbsp;</p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText"><font color="#000000" size="3" face="Consolas">sudo apt-get install xorg-dev</font></p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText">&nbsp;</p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText">And then issue again the usual installation commands:</p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText">&nbsp;</p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText"><font color="#000000" size="3" face="Consolas">perl Makefile.PL</font></p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText"><font color="#000000" size="3" face="Consolas">make</font></p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText"><font color="#000000" size="3" face="Consolas">make test</font></p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText"><font color="#000000" size="3" face="Consolas">make install</font></p>
<p style="MARGIN: 0cm 0cm 0pt" class="MsoPlainText"><font color="#000000" size="3" face="Consolas"></font><br />I have notified this issue to the module author, and asked him to update the Readme.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Hard Disk Head Crash</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2009/09/hard-disk-head-crash.html" />
    <id>tag:www.haboogo.com,2009:/matching_patterns//1.15</id>

    <published>2009-09-08T17:21:24Z</published>
    <updated>2009-09-08T20:46:21Z</updated>

    <summary><![CDATA[One month ago, shortly after the YAPC::EU 2009,&nbsp;my MacBook's hard disk died due to a head crash&nbsp;with only 2 years and 2 months. I used it intensively, but didn't expect such a short life. &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Farewell, Seagate...]]></summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[<p>One month ago, shortly after the YAPC::EU 2009,&nbsp;my MacBook's hard disk died due to a <a href="http://en.wikipedia.org/wiki/Head_crash">head crash</a>&nbsp;with only 2 years and 2 months. I used it intensively, but didn't expect such a short life.</p>
<p>&nbsp;<img style="TEXT-ALIGN: center; MARGIN: 0px auto 20px; DISPLAY: block" class="mt-image-center" alt="head_crash.jpg" src="http://www.haboogo.com/matching_patterns/head_crash.jpg" width="512" height="384" /></p>
<p>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <em>Farewell, Seagate ST9160821AS</em><span style="FONT-FAMILY: 'Trebuchet MS', 'sans-serif'; COLOR: #576a7b; FONT-SIZE: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: ES; mso-fareast-language: JA; mso-bidi-language: AR-SA"><strong><font face="Trebuchet MS"> </font></strong></span></p>
<p>It could have been worse (e.g., a battery blast on my lap...&nbsp;ouch! I always use&nbsp;a lapdesk since I considered this possibility, not as remote as you might think, given the latest news related to explosions of Apple products), but I lost&nbsp;a lot of info, mainly blog posts related to programming. Fortunately, I had a backup of the most important stuff.&nbsp;The really good news is that now I will only need another two hundred years to process what's left (the disk failure trimmed around half a millennium from my backlog).</p>
<p>Anyway, I've already installed a new HD, a Seagate ST9500420ASG with 500 GB capacity and I should receive Snow Leopard anytime soon.</p>
<p>
<span style="DISPLAY: inline" class="mt-enclosure mt-enclosure-image">&nbsp;</span></p>]]>
        
    </content>
</entry>

<entry>
    <title>WWW::Translate::Apertium Update</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2009/04/wwwtranslateapertium-v010-released.html" />
    <id>tag:www.haboogo.com,2009:/matching_patterns//1.13</id>

    <published>2009-04-12T01:01:00Z</published>
    <updated>2009-04-12T01:01:59Z</updated>

    <summary>WWW::Translate::Apertium v0.10 is now available on CPAN.This update fixes a bug due to a recent change in the I/O format of the Apertium web service.The developers changed the deformatter from txt to html, so the results contained html entitiesinstead of the actual...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[<a href="http://search.cpan.org/~enell/WWW-Translate-Apertium-0.10/lib/WWW/Translate/Apertium.pm">WWW::Translate::Apertium v0.10</a> is now available on CPAN.<div>This update fixes a bug due to a recent change in the I/O format of the Apertium web service.</div><div>The developers changed the deformatter from txt to html, so the results contained html entities</div><div>instead of the actual extended characters. </div><div>Since there's a lot of activity going on in the <a href="http://wiki.apertium.org/wiki/Main_Page" style="text-decoration: underline; ">Apertium</a> project (it's one of the organizations accepted</div><div>into Google Summer of Code 2009), I will set up a daily cron job to check for any changes that may</div><div>require an update, to avoid getting caught off guard again.</div><div><br /></div><div>This update also includes support for new language pairs:</div><div>Occitan &lt; > Spanish, Portuguese &lt; > Catalan, Portuguese &lt; > Galician, </div><div>and English > Esperanto (single-direction).</div>]]>
        
    </content>
</entry>

<entry>
    <title>10th Anniversary</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2009/02/10th-anniversay.html" />
    <id>tag:www.haboogo.com,2009:/matching_patterns//1.11</id>

    <published>2009-02-27T09:50:00Z</published>
    <updated>2009-02-28T00:05:53Z</updated>

    <summary>Ten years ago, I quit a permanent Project Manager position in a software localization company to start a freelance career, with the hope of being able to devote more time to pursue other interests. I don&apos;t mind working long hours on my...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[<p>Ten years ago, I quit a permanent Project Manager position in a software localization company to start a freelance career, with the hope of being able to devote more time to pursue other interests. I don't mind working long hours on my own projects, but a <em>workaholic</em> life was definitely not for me (although, occasionally, I still eat a 'late night pizza' in remembrance of the good ol' <em><a href="http://en.wikipedia.org/wiki/Karoshi">karoshi</a></em>-candidate days.)</p>
<p>I have not fully achieved the downshifting I planned originally, but at least my work-life balance is quite better, and I ended up living a peaceful life close to the beach, in <a href="http://www.cambrils-tourism.com/en/video.php?op=vid">Cambrils</a>, a nice Mediterranean village. That's something to celebrate... Today I will let my wife defeat me again at the tennis court.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Hot Books Basket(s)</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2009/02/hot-books-baskets.html" />
    <id>tag:www.haboogo.com,2009:/matching_patterns//1.10</id>

    <published>2009-02-20T14:47:25Z</published>
    <updated>2009-02-21T19:51:02Z</updated>

    <summary>I got tired of wading through piles of books and papers in my home office.A little &quot;domestic pressure&quot; and my own sense of uneasiness made me think of possible strategies to turn the cave back into, well, a plain office.As...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[I got tired of wading through piles of books and papers in my home office.<div>A little "domestic pressure" and my own sense of uneasiness made me think of possible strategies to turn the cave back into, well, a plain office.</div><div>As a first measure, I selected some books I'm not using anymore to give away. I then thought that it would be a good idea to put my 'hot books' (a term I use to refer to the books I'm reading or plan to read soon, and the books I use frequently as a reference) in a basket, next to my reading chair. And so I did.</div><div><br /></div><div>'Hot Books' Basket #1:</div><div><br /><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="hotbooks1.jpg" src="http://www.haboogo.com/matching_patterns/hotbooks1.jpg" width="640" height="480" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></span></div><div><br /></div><div>It soon became clear that one basket wouldn't be enough. Besides, I still had the left flank available. So I bought another basket and quickly filled it with more books.</div><div><br /></div><div>'Hot Books' Basket #2:</div><div><br /></div><div><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="hotbooks2.jpg" src="http://www.haboogo.com/matching_patterns/hotbooks2.jpg" width="640" height="480" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></span></div><div>I couldn't fit in all of them... Anyway, the room is so tidy now that I won't have to leave the usual trail of breadcrumbs to find my way back anymore<span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: -webkit-sans-serif; line-height: 19px; ">. <span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: arial; line-height: normal; ">And the great thing is that now I keep (almost) all of my 'hot books' at my fingertips.</span></span></div>]]>
        
    </content>
</entry>

<entry>
    <title>UTF-16 Processing Issue in Perl</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2009/01/utf-16-processing-issue-in-perl.html" />
    <id>tag:www.haboogo.com,2009:/matching_patterns//1.9</id>

    <published>2009-01-28T01:07:33Z</published>
    <updated>2009-02-28T00:14:17Z</updated>

    <summary>Here is an interesting piece of information on how to avoid problems while editing UTF-16|32 files using Perl. Some time ago I wanted to read an UTF-16LE-encoded XML file, modify some strings, and then write out the updated version. I...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[Here is an interesting piece of information on how to avoid problems while editing UTF-16|32 files using Perl.<br>

Some time ago I wanted to read an UTF-16LE-encoded XML file, modify some strings, and then write out the<br> updated version.
I followed the guidelines to transform the encoding to Perl's internal format using PerlIO:<br><br>

<font color="#b02f60"><b>open</b></font>&nbsp;<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$in</font>, <font color="#4a6f8b">&quot;</font><font color="#4a6f8b">&lt;:encoding(UTF-16LE)</font><font color="#4a6f8b">&quot;</font>, <font color="#458b73">$in_path</font>;
<br>
<font color="#0000ed"><i># some code goes here</i></font>
<br>
<font color="#b02f60"><b>open</b></font>&nbsp;<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$out</font>, <font color="#4a6f8b">&quot;</font><font color="#4a6f8b">&gt;:encoding(UTF-16LE)</font><font color="#4a6f8b">&quot;</font>, <font color="#458b73">$out_path</font>;<br><br>

but couldn't make it work right this way. The extended characters weren't displayed correctly.

After doing some research on the Internet, I found a solution in <a href="http://www.mail-archive.com/perl-unicode@perl.org/msg02615.html">this thread</a> of the perl-unicode list.
Dan Kogai mentions that BOMed UTF files are not suitable for streaming models, and
they must be slurped as binary files instead:<br><br>

<font color="#0000ed"><i># read file</i></font><br>
<font color="#b02f60"><b>open</b></font>(<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$in</font>, <font color="#4a6f8b">'</font><font color="#4a6f8b">&lt;:raw</font><font color="#4a6f8b">'</font>, <font color="#458b73">$in_path</font>) || <font color="#b02f60"><b>die</b></font>&nbsp;<font color="#4a6f8b">&quot;</font><font color="#4a6f8b">Couldn't open file: </font><font color="#458b73">$!</font><font color="#4a6f8b">&quot;</font>;<br>
<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$text</font>&nbsp;= <font color="#b02f60"><b>do</b></font>&nbsp;{ <font color="#b02f60"><b>local</b></font>&nbsp;<font color="#458b73">$/</font>; &lt;<font color="#458b73">$in</font>&gt; };<br>
<font color="#b02f60"><b>close</b></font>&nbsp;<font color="#458b73">$in</font>;<br>
<br>
<font color="#0000ed"><i># now decode to use character semantics (no need to specify LE or BE when reading)</i></font><br>
<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$content</font>&nbsp;= decode(<font color="#4a6f8b">'</font><font color="#4a6f8b">UTF-16LE</font><font color="#4a6f8b">'</font>, <font color="#458b73">$text</font>); <br>
<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">@lines</font>&nbsp;= <font color="#b02f60"><b>split</b></font><font color="#b02f60"><b>&nbsp;/</b></font><font color="#8a2ae2">\n</font><font color="#b02f60"><b>/</b></font>, <font color="#458b73">$content</font>;<br>
<br>
<font color="#0000ed"><i># some code that turns @lines into @processed goes here</i></font><br>
<br>
<font color="#0000ed"><i># write file</i></font><br>
<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$output_str</font>&nbsp;= <font color="#b02f60"><b>join</b></font>&nbsp;<font color="#4a6f8b">&quot;</font><font color="#8a2ae2">\n</font><font color="#4a6f8b">&quot;</font>, <font color="#458b73">@processed</font>;<br>
<br>
<font color="#b02f60"><b>open</b></font>&nbsp;<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$out</font>, <font color="#4a6f8b">'</font><font color="#4a6f8b">&gt;:raw</font><font color="#4a6f8b">'</font>, <font color="#458b73">$out_path</font>;<br>
<font color="#b02f60"><b>print</b></font>&nbsp;<font color="#458b73">$out</font>&nbsp;encode(<font color="#4a6f8b">&quot;</font><font color="#4a6f8b">UTF-16LE</font><font color="#4a6f8b">&quot;</font>, <font color="#458b73">$output_str</font>);<br>
<font color="#b02f60"><b>close</b></font>&nbsp;<font color="#458b73">$out</font>;<br>
</font><br>

and that did the trick.]]>
        
    </content>
</entry>

<entry>
    <title>Code Syntax Highlighting</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2009/01/code-syntax-highlighting.html" />
    <id>tag:www.haboogo.com,2009:/matching_patterns//1.8</id>

    <published>2009-01-04T00:29:24Z</published>
    <updated>2009-01-05T23:41:00Z</updated>

    <summary>I found an easy way of adding code samples with syntax highlighting to my blog entries, based on a &quot;conversion to html&quot; procedure in Vim. This method is valid for all the languages supported by Vim. Select the code in...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[I found an easy way of adding code samples with syntax highlighting to my blog entries, based on a "conversion to html" procedure in Vim. This method is valid for all the languages  supported by Vim.<p> <p>
Select the code in the editor and type <b>:TOhtml</b>. This command opens a new buffer containing your code converted to html (including the colors). Now you only have to copy the html code and paste it to your entry.<br/>
As an example, here's my solution to Project Euler's #2:<p>


<font color="#1773cc">#!/usr/bin/perl -w</font><br>
<font color="#b02f60"><b>use strict</b></font>;<br>
<font color="#b02f60"><b>use </b></font>feature <font color="#4a6f8b">'</font><font color="#4a6f8b">say</font><font color="#4a6f8b">'</font>;<br>
<font color="#b02f60"><b>use </b></font>Memoize;<br>
<br>
memoize(<font color="#4a6f8b">'</font><font color="#4a6f8b">fib</font><font color="#4a6f8b">'</font>);<br>
<br>
<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$n</font>&nbsp;= <font color="#ff8b00">1</font>;<br>
<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$fib</font>&nbsp;= fib(<font color="#458b73">$n</font>);<br>
<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$sum</font>&nbsp;= <font color="#ff8b00">0</font>;<br>
<br>
<font color="#b02f60"><b>while</b></font>&nbsp;(<font color="#458b73">$fib</font>&nbsp;&lt; <font color="#ff8b00">1_000_000</font>) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#b02f60"><b>if</b></font>&nbsp;(<font color="#458b73">$fib</font>&nbsp;% <font color="#ff8b00">2</font>&nbsp;== <font color="#ff8b00">0</font>) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;say <font color="#458b73">$fib</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#458b73">$sum</font>&nbsp;+= <font color="#458b73">$fib</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#458b73">$n</font>++;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#458b73">$fib</font>&nbsp;= fib(<font color="#458b73">$n</font>);<br>
}<br>
<br>
say <font color="#4a6f8b">&quot;</font><font color="#4a6f8b">Result: </font><font color="#458b73">$sum</font><font color="#4a6f8b">&quot;</font>;<br>
<br>
<br>
<font color="#b02f60"><b>sub</b></font><font color="#458b73">&nbsp;</font><font color="#458b73">fib</font><font color="#458b73">&nbsp;</font>{<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#b02f60"><b>my</b></font>&nbsp;<font color="#458b73">$n</font>&nbsp;= <font color="#b02f60"><b>shift</b></font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#b02f60"><b>return</b></font>&nbsp;<font color="#ff8b00">1</font>&nbsp;<font color="#b02f60"><b>if</b></font>&nbsp;<font color="#458b73">$n</font>&nbsp;&lt; <font color="#ff8b00">2</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;fib (<font color="#458b73">$n</font><font color="#ff8b00">-1</font>) + fib(<font color="#458b73">$n</font><font color="#ff8b00">-2</font>); <br>
}<br>
</font>

<p><p>
As you can see, the code coloring functionality of a default setup of MacVim doesn't recognize the new Perl 5.10 features (like the <b>say</b> function), but the result is quite readable.<p>
NOTE: For an MT4 blog, the entry format should be <b>None</b> (pure HTML).<p>

There is a similar solution for Emacs/XEmacs users. You can find the details here: 

<a href="https://vgoulet.act.ulaval.ca/svn/emacs-modified/trunk/htmlize.el">htmlize</a>.
<p>]]>
        
    </content>
</entry>

<entry>
    <title>Movable Type</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2009/01/movable-type.html" />
    <id>tag:www.haboogo.com,2009:/matching_patterns//1.7</id>

    <published>2009-01-03T17:28:41Z</published>
    <updated>2009-01-03T23:48:40Z</updated>

    <summary>After a slow start, I have resumed work on my blog. The free weblogs provided by Wordpress.com are nice, but I wanted a more flexible solution, so today I installed Movable Type (which is written in Perl) on my server...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[<div>After a slow start, I have resumed work on my blog. The free weblogs provided by Wordpress.com are nice, but I wanted a more flexible solution, so today I installed Movable Type (which is written in Perl) on my server and migrated the blog. So far so good.</div><div>Now I'm checking the different options to add code syntax-highlighting functionality to my posts. It seems that the available plugins are outdated and won't work well with MT4, but there are other possibilities...</div>]]>
        
    </content>
</entry>

<entry>
    <title>Spanish Perl mongers in Copenhagen</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2008/09/spanish-perl-mongers-in-copenhagen.html" />
    <id>tag:www.haboogo.com,2008:/matching_patterns//1.6</id>

    <published>2008-09-06T16:00:19Z</published>
    <updated>2009-01-04T22:26:36Z</updated>

    <summary>Once again, I had a great time at the YAPC. Lots of interesting talks, free lunch bag, and the chance to meet new people. Too bad they only announced the tutorials in mid-July, when most of us already had our...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
        <category term="Uncategorized" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="yapc" label="YAPC" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[Once again, I had a great time at the YAPC. Lots of interesting talks, free lunch bag, and the chance to meet new people. Too bad they only announced the tutorials in mid-July, when most of us already had our plane tickets. Here is a picture of the Spanish Perl mongers who attended the YAPC::EU 2008, a dangerous bunch conspiring to organize the first Spanish Perl Workshop:<div><br /></div><div><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="yapc_2008.jpg" src="http://www.haboogo.com/matching_patterns/images/yapc_2008.jpg" width="439" height="359" class="mt-image-none" style="" /></span></div><div><br /><div>From left to right: Roberto Henríquez, Emmanuel Rodríguez, Diego Kuperman, Casiano Rodríguez León,               Salvador Fandiño and me.</div><div><div><br /></div></div></div>]]>
        
    </content>
</entry>

<entry>
    <title>Introduction</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2008/07/my-very-first-blog-post.html" />
    <id>tag:www.haboogo.com,2008:/matching_patterns//1.5</id>

    <published>2008-07-07T15:43:08Z</published>
    <updated>2009-01-03T14:56:27Z</updated>

    <summary>Well, I finally decided to start my own blog, where I will write on subjects mostly related to programming, focusing on its applications in the fields of technical translation and software localization. I was given my first computer -a Sinclair ZX...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
        <category term="Uncategorized" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="f" label="F#" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ocaml" label="OCaml" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="powershell" label="PowerShell" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="regularexpressions" label="regular expressions" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="softwarelocalization" label="software localization" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="technicaltranslation" label="technical translation" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA[Well, I finally decided to start my own blog, where I will write on subjects mostly related to programming, focusing on its applications in the fields of technical translation and software localization.

<span>I was given my first computer -a Sinclair ZX Spectrum- a long time ago, and I’ve been having fun with computers ever since, specially since I discovered Perl and regular expressions at the beginning of the new century while reading <a title="Mastering Regular Expressions" href="http://regex.info/" target="_blank">Mastering Regular Expressions</a>, by Jeffrey Friedl (needless to say, it’s one of my favorite books). Perl is a powerful and flexible language, and it's perfect for text processing. Curiously enough, it is still not widely used in the translation industry. Hopefully, this blog's posts will contribute to increase its popularity among translators and software localization engineers.</span>

<span>Even though I use Perl for most of my programs, learning other languages is a healthy attitude, so I’m currently learning a couple of nice functional languages, F# and OCaml, which are giving me interesting perspectives on different ways of doing things. I also plan to learn PowerShell, a new dynamic language created by Microsoft, and compare it to Perl. </span>

<span>I will keep you posted.</span>]]>
        
    </content>
</entry>

<entry>
    <title>Confessions</title>
    <link rel="alternate" type="text/html" href="http://www.haboogo.com/matching_patterns/2008/07/confessions.html" />
    <id>tag:www.haboogo.com,2008:/matching_patterns//1.4</id>

    <published>2008-07-07T15:40:56Z</published>
    <updated>2009-01-03T17:26:57Z</updated>

    <summary>&quot;Who can unravel such a twisted and tangled knottiness? It is unclean. I hate to reflect upon it. I hate to look on it. But I do long for thee, O Righteousness and Innocence, so beautiful and comely to all...</summary>
    <author>
        <name>Enrique Nell</name>
        
    </author>
    
        <category term="Uncategorized" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-US" xml:base="http://www.haboogo.com/matching_patterns/">
        <![CDATA["Who can unravel such a twisted and tangled knottiness? It is unclean. I hate to reflect upon it. I hate to look on it. But I do long for thee, O Righteousness and Innocence, so beautiful and comely to all virtuous eyes -- I long for thee with an insatiable satiety. With thee is perfect rest, and life unchanging. He who enters into thee enters into the joy of his Lord, and shall have no fear and shall achieve excellence in the Excellent. I fell away from thee, O my God, and in my youth I wandered too far from thee, my true support. And I became to myself a wasteland."

 <div>St. Augustine Confessions, Book II, Chapter X.</div>]]>
        
    </content>
</entry>

</feed>

