<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5799967069743366924</id><updated>2011-07-31T04:38:50.499+04:00</updated><category term='i18n'/><category term='MySQL'/><category term='santa cruz'/><category term='claus grabke'/><category term='capitalization'/><category term='stored procedure'/><category term='perl'/><category term='localization'/><category term='git-gui'/><category term='DBI'/><category term='text manipulation'/><category term='File::Find'/><category term='l10'/><category term='lyrics'/><category term='proper case'/><category term='eight dayz'/><category term='gitk'/><category term='internationalization'/><category term='Archive::Tar'/><category term='archive'/><category term='LOAD DATA INFILE'/><category term='git'/><category term='questions'/><category term='what’s so strange about me'/><category term='examples'/><title type='text'>chhh, quiet plxplx...</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://3rdaftergod.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://3rdaftergod.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>chhh</name><uri>http://www.blogger.com/profile/05577280816824461817</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://lh5.ggpht.com/_tv3eLQ80syw/SWKP-qY0pdI/AAAAAAAADDU/sRHJQfgAjBI/s576/IMG_0581.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5799967069743366924.post-8721090783168180070</id><published>2011-04-29T21:48:00.004+04:00</published><updated>2011-04-29T22:00:50.857+04:00</updated><title type='text'>Don't forget to turn on mysql strict mode</title><content type='html'>One day I noticed that ALL the tables on our DB server were MyISAM. I was kind of shocked by such news. Not that we were using transactions or something, but the create statements clearly set the storage engine to InnoDB for most important tables. After moving to new harware nobody ever checked DB engine that was used after DB migration. Turned out, mysql silently ignored those statements (innodb was turned off in my.cnf at the moment of DB restoration).&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sql-mode="STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;This line should reside in your my.cnf/my.ini file. It will save you from such situations as well as save you from seemingly successfull attempts to put a string value into a TINYINT column or something.&lt;br /&gt;&lt;br /&gt;the bare minimum is:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sql-mode="NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;after making those changes don't forget to restart mysqld.&lt;br /&gt;If you don't want to restart your server, you can set this variable through executing an SQL query, e.g.:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SET @@global.sql_mode= '';&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;for completely disabling strict mode.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5799967069743366924-8721090783168180070?l=3rdaftergod.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3rdaftergod.blogspot.com/feeds/8721090783168180070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3rdaftergod.blogspot.com/2011/04/dont-forget-to-turn-on-mysql-strict.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/8721090783168180070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/8721090783168180070'/><link rel='alternate' type='text/html' href='http://3rdaftergod.blogspot.com/2011/04/dont-forget-to-turn-on-mysql-strict.html' title='Don&apos;t forget to turn on mysql strict mode'/><author><name>chhh</name><uri>http://www.blogger.com/profile/05577280816824461817</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://lh5.ggpht.com/_tv3eLQ80syw/SWKP-qY0pdI/AAAAAAAADDU/sRHJQfgAjBI/s576/IMG_0581.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5799967069743366924.post-4639826530371724821</id><published>2011-04-25T16:05:00.004+04:00</published><updated>2011-04-25T16:37:15.658+04:00</updated><title type='text'>dbg-php-5.3 + apache 2.2 + phped = The Quest</title><content type='html'>Moving from PHP 5.2 to 5.3 was going to be a seamless update... in theory.&lt;br /&gt;I've downloaded php 5.3.6, which now only comes compiled by VC9 and that's where the problems began. By that time I have long forgotten that my apache was VC6 version from apache.org.&lt;br /&gt;So if you want to use Apache 2.2, PHP &amp;gt;=5.3.6 and dbg-php-5.3.dll your only option seems to move to VC9 versions of all those packages.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Apache&lt;/span&gt;&lt;br /&gt;The latest VC9 version can be grabbed at &lt;a href="http://www.apachelounge.com/download/"&gt;apachelounge&lt;/a&gt;. It can be used as a drop in replacement for your existing apache 2.2 installation, just don't forget to NOT overwrite your original httpd.conf file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PHP&lt;/span&gt;&lt;br /&gt;Windows binaries are available at &lt;a href="http://windows.php.net/download/"&gt;php.net&lt;/a&gt;, you should opt for Thread Safe (TS) VC9 version.&lt;br /&gt;After it's installation I've encountered a weird problem, which was not obvious at all - php didn't find the correct php.ini file, even though the right PHPIniDir was set in httpd.conf. The only solution for this was moving php.ini to my Windows directory.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;dbg-php-5.3&lt;/span&gt;&lt;br /&gt;After two previous steps are done, simply don't forget to choose the right dbg-php-5.3 for your platform and don't forget to use it's VC9 flavour. For me it was x86_VC9.&lt;br /&gt;&lt;br /&gt;Hope this helps someone someday.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5799967069743366924-4639826530371724821?l=3rdaftergod.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3rdaftergod.blogspot.com/feeds/4639826530371724821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3rdaftergod.blogspot.com/2011/04/dbg-php-53-apache-22-phped-quest.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/4639826530371724821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/4639826530371724821'/><link rel='alternate' type='text/html' href='http://3rdaftergod.blogspot.com/2011/04/dbg-php-53-apache-22-phped-quest.html' title='dbg-php-5.3 + apache 2.2 + phped = The Quest'/><author><name>chhh</name><uri>http://www.blogger.com/profile/05577280816824461817</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://lh5.ggpht.com/_tv3eLQ80syw/SWKP-qY0pdI/AAAAAAAADDU/sRHJQfgAjBI/s576/IMG_0581.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5799967069743366924.post-3488155403842558144</id><published>2011-03-30T05:00:00.013+04:00</published><updated>2011-03-31T02:55:43.542+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lyrics'/><category scheme='http://www.blogger.com/atom/ns#' term='eight dayz'/><category scheme='http://www.blogger.com/atom/ns#' term='santa cruz'/><category scheme='http://www.blogger.com/atom/ns#' term='claus grabke'/><category scheme='http://www.blogger.com/atom/ns#' term='questions'/><category scheme='http://www.blogger.com/atom/ns#' term='what’s so strange about me'/><title type='text'>Eight Dayz - What's so strange about me?</title><content type='html'>band:  eight dayz (also covered by trevor 'trouble' andrew)&lt;br /&gt;album: ev’ry day is like a new beginning&lt;br /&gt;song:  what’s so strange about me&lt;br /&gt;year:  1988&lt;br /&gt;&lt;br /&gt;I've found only a few versions of lyrics, most of which were confusing. So i decided to post my version here (at least that's what i hear) (some parts, that deserve attention compared to other lyrics you might find on the web are emphasized with bold text and underlined):&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Whereever I am going&lt;br /&gt;they’re calling me a stranger&lt;br /&gt;they’re calling me a liar&lt;br /&gt;they’re calling me a &lt;b&gt;&lt;u&gt;thief&lt;/u&gt;&lt;/b&gt; &lt;strike&gt;gypsy&lt;/strike&gt;&lt;br /&gt;&lt;br /&gt;say take away the children&lt;br /&gt;take away the work&lt;br /&gt;&lt;b&gt;&lt;u&gt;they disfavour&lt;/u&gt;&lt;/b&gt; my behaviour&lt;br /&gt;tell me by my smell&lt;br /&gt;&lt;b&gt;&lt;u&gt;they disfavour&lt;/u&gt;&lt;/b&gt; my behaviour&lt;br /&gt;tell me by my smell&lt;br /&gt;&lt;br /&gt;&lt;b&gt;chorus:&lt;/b&gt;&lt;br /&gt;what's so strange about me&lt;br /&gt;i know the same with you&lt;br /&gt;just cuz i'm far away from home&lt;br /&gt;you say i don't belong to you&lt;br /&gt;&lt;br /&gt;you want me to shine on my culture&lt;br /&gt;the things that &lt;b&gt;&lt;u&gt;i've&lt;/u&gt;&lt;/b&gt; learned&lt;br /&gt;you want the total adaption&lt;br /&gt;the pride that &lt;b&gt;&lt;u&gt;i've&lt;/u&gt;&lt;/b&gt; earned&lt;br /&gt;&lt;br /&gt;but what remains as a question&lt;br /&gt;i'd like to ask you&lt;br /&gt;as soon as i fit in&lt;br /&gt;who are you gonna bring the bad thigs to?&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;yeah&lt;/u&gt;&lt;/b&gt;, they think &lt;b&gt;&lt;u&gt;they've&lt;/u&gt;&lt;/b&gt; got a reason&lt;br /&gt;so they're looking down on us&lt;br /&gt;but &lt;b&gt;&lt;u&gt;in fact&lt;/u&gt;&lt;/b&gt; they're only using us&lt;br /&gt;as a bad excuse&lt;br /&gt;&lt;b&gt;&lt;u&gt;for the mistakes that they're making &lt;br /&gt;the bad things on this earth&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;they disfavour&lt;/u&gt;&lt;/b&gt; our behaviour&lt;br /&gt;tell us by our smell&lt;br /&gt;&lt;b&gt;&lt;u&gt;they disfavour&lt;/u&gt;&lt;/b&gt; our behaviour&lt;br /&gt;tell us by our smell&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5799967069743366924-3488155403842558144?l=3rdaftergod.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3rdaftergod.blogspot.com/feeds/3488155403842558144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3rdaftergod.blogspot.com/2011/03/eight-dayz-whats-so-strange-about-me.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/3488155403842558144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/3488155403842558144'/><link rel='alternate' type='text/html' href='http://3rdaftergod.blogspot.com/2011/03/eight-dayz-whats-so-strange-about-me.html' title='Eight Dayz - What&apos;s so strange about me?'/><author><name>chhh</name><uri>http://www.blogger.com/profile/05577280816824461817</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://lh5.ggpht.com/_tv3eLQ80syw/SWKP-qY0pdI/AAAAAAAADDU/sRHJQfgAjBI/s576/IMG_0581.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5799967069743366924.post-6424659095712745303</id><published>2010-04-15T18:23:00.003+04:00</published><updated>2010-04-15T18:34:57.707+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='internationalization'/><category scheme='http://www.blogger.com/atom/ns#' term='l10'/><category scheme='http://www.blogger.com/atom/ns#' term='git'/><category scheme='http://www.blogger.com/atom/ns#' term='gitk'/><category scheme='http://www.blogger.com/atom/ns#' term='localization'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><category scheme='http://www.blogger.com/atom/ns#' term='git-gui'/><title type='text'>Remove localization (l10n, i18n) from git gui and gitk</title><content type='html'>I think such tools as git should not be translated into other languages, this only makes it cumbersome to figure out a 1:1 relation to the original English version. And e.g. Russian version of git-gui looks horrible, because fonts have huge spacings for some reason.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt; - just remove/rename the following 2 items:&lt;br /&gt;   1) &lt;strong&gt;&amp;lt;git installation path&amp;gt;/share/git-gui/lib/msgs&lt;/strong&gt;&lt;br /&gt;   2) &lt;strong&gt;&amp;lt;git installation path&amp;gt;/share/gitk/lib/msgs&lt;/strong&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5799967069743366924-6424659095712745303?l=3rdaftergod.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3rdaftergod.blogspot.com/feeds/6424659095712745303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3rdaftergod.blogspot.com/2010/04/remove-localization-l10n-i18n-from-git.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/6424659095712745303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/6424659095712745303'/><link rel='alternate' type='text/html' href='http://3rdaftergod.blogspot.com/2010/04/remove-localization-l10n-i18n-from-git.html' title='Remove localization (l10n, i18n) from git gui and gitk'/><author><name>chhh</name><uri>http://www.blogger.com/profile/05577280816824461817</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://lh5.ggpht.com/_tv3eLQ80syw/SWKP-qY0pdI/AAAAAAAADDU/sRHJQfgAjBI/s576/IMG_0581.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5799967069743366924.post-7099187197068665527</id><published>2010-02-16T01:10:00.009+03:00</published><updated>2010-02-16T01:41:35.708+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='text manipulation'/><category scheme='http://www.blogger.com/atom/ns#' term='proper case'/><category scheme='http://www.blogger.com/atom/ns#' term='perl'/><category scheme='http://www.blogger.com/atom/ns#' term='capitalization'/><title type='text'>Proper case function in Perl</title><content type='html'>if you, like me, consider&lt;br /&gt;&lt;br /&gt;&lt;div class='code'&gt;print ucfirst lc for split /\b/;&lt;/div&gt;&lt;br /&gt;not enough of a 'proper' case, then try this function (taken from this thread &lt;a href='http://www.webmasterworld.com/forum13/1673.htm'&gt;http://www.webmasterworld.com/forum13/1673.htm&lt;/a&gt;, thx &lt;strong&gt;hiker_jjw&lt;/strong&gt;)&lt;br /&gt;&lt;br /&gt;&lt;div class='code'&gt;&lt;br /&gt;#!/usr/local/bin/perl&lt;br /&gt;#&lt;br /&gt;# test.cgi&lt;br /&gt;#&lt;br /&gt;$¦ = 1;&lt;br /&gt;print "Content-type: text/html\n\n";&lt;br /&gt;&lt;br /&gt;$string = "IS D.H. LAWRENCE'S LADY: (DE'ALOUME E'FRENCHE'S)";&lt;br /&gt;print "\n\n$string\n\n";&lt;br /&gt;$new_string = &amp;make_proper($string);&lt;br /&gt;print "$new_string\n\n";&lt;br /&gt;&lt;br /&gt;$string = "THIS IS A TESTING'S VOLUME I.";&lt;br /&gt;print "\n\n$string\n\n";&lt;br /&gt;$new_string = &amp;make_proper($string);&lt;br /&gt;print "$new_string\n\n";&lt;br /&gt;&lt;br /&gt;exit;&lt;br /&gt;&lt;br /&gt;sub make_proper&lt;br /&gt;{&lt;br /&gt;my ($string) = @_;&lt;br /&gt;my @words = split (/\s+/, lc $string);&lt;br /&gt;my @new_words = ();&lt;br /&gt;my $new_word = "";&lt;br /&gt;&lt;br /&gt;foreach my $word (@words) {&lt;br /&gt;&lt;br /&gt;# Starts with Non-Alphanum Character&lt;br /&gt;my $starting_non_alphanum = "";&lt;br /&gt;if ($word =~ /^(\W)+(.*)/) {&lt;br /&gt;$starting_non_alphanum = $1;&lt;br /&gt;$word = $2;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# Ends with Non-Alphanum Character&lt;br /&gt;my $ending_non_alphanum = "";&lt;br /&gt;if ($word =~ /(.*)(\W)+$/) {&lt;br /&gt;$word = $1;&lt;br /&gt;$ending_non_alphanum = $2;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# Contains a Non-Alphanum Character&lt;br /&gt;if ($word =~ /^(\w+)(\W)(\w+)(\W?)(\w?)$/) {&lt;br /&gt;my $p1_word = $1;&lt;br /&gt;my $p2_non_alphanum = $2;&lt;br /&gt;my $p3_word = $3;&lt;br /&gt;my $p4_non_alphanum = $4;&lt;br /&gt;my $p5_letter = $5;&lt;br /&gt;&lt;br /&gt;$p1_word = ucfirst $p1_word;&lt;br /&gt;$p5_letter = lc $p5_letter;&lt;br /&gt;if (length $p1_word &gt; 2 &amp;&amp; length $p3_word == 1) {&lt;br /&gt;$p3_word = lc $p3_word;&lt;br /&gt;} elsif (length $p1_word == 1 &amp;&amp; length $p3_word == 1) {&lt;br /&gt;$p3_word = uc $p3_word;&lt;br /&gt;} else {&lt;br /&gt;$p3_word = ucfirst $p3_word;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$new_word = $p1_word . $p2_non_alphanum . $p3_word . $p4_non_alphanum . $p5_letter;&lt;br /&gt;&lt;br /&gt;# Other&lt;br /&gt;} else {&lt;br /&gt;$new_word = ucfirst $word;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# Recombine the Alphanum Character&lt;br /&gt;$new_word = $starting_non_alphanum . $new_word . $ending_non_alphanum;&lt;br /&gt;&lt;br /&gt;push (@new_words, $new_word);&lt;br /&gt;}&lt;br /&gt;my $new_string = join(" ", @new_words);&lt;br /&gt;&lt;br /&gt;$new_string =~ s/(\w,?) And (\w)/$1 and $2/g;&lt;br /&gt;$new_string =~ s/(\w,?) Or (\w)/$1 or $2/g;&lt;br /&gt;$new_string =~ s/(\w,?) But (\w)/$1 but $2/g;&lt;br /&gt;&lt;br /&gt;$new_string =~ s/(\w) At (\w)/$1 at $2/g;&lt;br /&gt;$new_string =~ s/(\w) In (\w)/$1 in $2/g;&lt;br /&gt;$new_string =~ s/(\w) On (\w)/$1 on $2/g;&lt;br /&gt;$new_string =~ s/(\w) To (\w)/$1 to $2/g;&lt;br /&gt;$new_string =~ s/(\w) From (\w)/$1 from $2/g;&lt;br /&gt;&lt;br /&gt;$new_string =~ s/(\w) Is (\w)/$1 is $2/g;&lt;br /&gt;$new_string =~ s/(\w) A (\w)/$1 a $2/g;&lt;br /&gt;$new_string =~ s/(\w) An (\w)/$1 an $2/g;&lt;br /&gt;$new_string =~ s/(\w) Am (\w)/$1 am $2/g;&lt;br /&gt;$new_string =~ s/(\w) For (\w)/$1 for $2/g;&lt;br /&gt;$new_string =~ s/(\w) Of (\w)/$1 of $2/g;&lt;br /&gt;$new_string =~ s/(\w) The (\w)/$1 the $2/g;&lt;br /&gt;&lt;br /&gt;if (length $new_string &gt; 60) {&lt;br /&gt;$new_string =~ s/(\w) With (\w)/$1 with $2/g; #?&lt;br /&gt;$new_string =~ s/(\w) That (\w)/$1 that $2/g; #?&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$new_string = ucfirst $new_string;&lt;br /&gt;&lt;br /&gt;return ($new_string);&lt;br /&gt;&lt;br /&gt;} # End sub make_proper &lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5799967069743366924-7099187197068665527?l=3rdaftergod.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3rdaftergod.blogspot.com/feeds/7099187197068665527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3rdaftergod.blogspot.com/2010/02/proper-case-function-in-perl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/7099187197068665527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/7099187197068665527'/><link rel='alternate' type='text/html' href='http://3rdaftergod.blogspot.com/2010/02/proper-case-function-in-perl.html' title='Proper case function in Perl'/><author><name>chhh</name><uri>http://www.blogger.com/profile/05577280816824461817</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://lh5.ggpht.com/_tv3eLQ80syw/SWKP-qY0pdI/AAAAAAAADDU/sRHJQfgAjBI/s576/IMG_0581.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5799967069743366924.post-4548227548093810874</id><published>2009-07-10T01:49:00.012+04:00</published><updated>2009-09-20T02:00:30.362+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='archive'/><category scheme='http://www.blogger.com/atom/ns#' term='File::Find'/><category scheme='http://www.blogger.com/atom/ns#' term='Archive::Tar'/><category scheme='http://www.blogger.com/atom/ns#' term='examples'/><category scheme='http://www.blogger.com/atom/ns#' term='perl'/><title type='text'>Archiving files with Perl (using only standard modules)</title><content type='html'>I stumbled upon this problem when decided to write an automated script for backing up my projects. The first solution was to use &lt;a href="http://search.cpan.org/~jmbo/Archive-Rar-1.9/Rar.pm"&gt;Archive::Rar&lt;/a&gt; module, but there are 2 catches: you need to have winRar installed and you need the Archive::Rar module itself.&lt;br /&gt;Finding this not acceptable, I looked into the Archive module to find the &lt;a href="http://search.cpan.org/dist/Archive-Tar/lib/Archive/Tar.pm"&gt;Archive::Tar&lt;/a&gt; quite good!&lt;br /&gt;&lt;br /&gt;The only problem was that it didn't want to simply archive a specified directory and all of it's contents, instead you need to provide the list of all the files you want archived in a list.&lt;br /&gt;&lt;br /&gt;If you simply provide it with a list of full absolute paths to files, you'll end up with the archive containing all your directory structure like having folders 'D:', 'Program Files', 'etc' and so on. What you can do is first &lt;a href="http://perldoc.perl.org/functions/chdir.html"&gt;chdir()&lt;/a&gt; (not everyone knows it's possible to change the current working directory from inside the script) to the directory one level above the one you're going to archive and then perform all operations relative to that path which is much more convinient.&lt;br /&gt;&lt;br /&gt;To add all the files in nested folders you have to recursively traverse the directory structure either manually or, for example, using &lt;a href="http://perldoc.perl.org/File/Find.html"&gt;File::Find&lt;/a&gt;. We'll do it th latter way as File::Find is also a standard perl module.&lt;br /&gt;&lt;br /&gt;(you can grab the full fledged version of the script &lt;a href="http://github.com/chhh/backup/blob/master/backup.pl"&gt;here&lt;/a&gt; [http://github.com/chhh/backup/blob/master/backup.pl])&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;use Archive::Tar;&lt;br /&gt;use File::Find;&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# assume you have the following folder for archiving &lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# d:/some_data/folder_for_archiving&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# you can work with this path and split it using RegEx or how &lt;br /&gt;# ever you like&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# you can also use Cwd module to get the absolute path like &lt;br /&gt;# this:&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;#    use Cwd qw/abs_path/;&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;#    my $abs_dir_path = abs_path($some_relative_path);&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# for this example we'll keep it even simpler&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;my $abs_dir_path = &lt;font color="#ff00ff"&gt;'d:/some_data/'&lt;/font&gt;;&lt;br /&gt;my $dir_name = &lt;font color="#ff00ff"&gt;'folder_for_archiving'&lt;/font&gt;;&lt;br /&gt;my $archive_filename = &lt;font color="#ff00ff"&gt;'archived_filder'&lt;/font&gt;;&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# changing the working directory&lt;/font&gt;&lt;br /&gt;chdir $abs_dir_path &lt;br /&gt;    or die &lt;font color="#ff00ff"&gt;&amp;quot;Can't change dir to $abs_dir_path: $!\n&amp;quot;&lt;/font&gt;;&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# The find() function recursively traverses the directory &lt;br /&gt;# structure returning&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# the name of each file in a special variable $File::Find::name,&lt;br /&gt;# it uses a&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# callback function for each file, here we used anonymous &lt;br /&gt;# function defined&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# right inside the find() call, that pushes each filename&lt;br /&gt;# to  our @files array.&lt;/font&gt;&lt;br /&gt;my @files;&lt;br /&gt;find(sub {push @files,$File::Find::name},$folder_for_archiving);&lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;# the 1st argument to Archive::Tar is the archive name, &lt;br /&gt;# 2nd level of&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt; compression (1-9), 3rd is argument list&lt;/font&gt;&lt;br /&gt;if ( !Archive::Tar-&amp;gt;create_archive( &lt;br /&gt;            &lt;font color="#ff00ff"&gt;&amp;quot;$abs_dir_path/$archive_filename.tar&amp;quot;&lt;/font&gt;,&lt;br /&gt;            5,&lt;br /&gt;            @files)) {&lt;br /&gt;    print &lt;font color="#ff00ff"&gt;&amp;quot;Archivation failed.\n&amp;quot;&lt;/font&gt;;&lt;br /&gt;}&lt;br /&gt;print &lt;font color="#ff00ff"&gt;&amp;quot;Archivation complete.\n&amp;quot;&lt;/font&gt;;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;(you can grab the full fledged version of the script &lt;a href="http://github.com/chhh/backup/blob/master/backup.pl"&gt;here&lt;/a&gt; [http://github.com/chhh/backup/blob/master/backup.pl])&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5799967069743366924-4548227548093810874?l=3rdaftergod.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3rdaftergod.blogspot.com/feeds/4548227548093810874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3rdaftergod.blogspot.com/2009/07/archiving-files-with-perl-using-only.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/4548227548093810874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/4548227548093810874'/><link rel='alternate' type='text/html' href='http://3rdaftergod.blogspot.com/2009/07/archiving-files-with-perl-using-only.html' title='Archiving files with Perl (using only standard modules)'/><author><name>chhh</name><uri>http://www.blogger.com/profile/05577280816824461817</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://lh5.ggpht.com/_tv3eLQ80syw/SWKP-qY0pdI/AAAAAAAADDU/sRHJQfgAjBI/s576/IMG_0581.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5799967069743366924.post-972571685372185873</id><published>2009-07-01T03:03:00.014+04:00</published><updated>2009-07-10T01:43:56.706+04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='LOAD DATA INFILE'/><category scheme='http://www.blogger.com/atom/ns#' term='examples'/><category scheme='http://www.blogger.com/atom/ns#' term='stored procedure'/><category scheme='http://www.blogger.com/atom/ns#' term='perl'/><category scheme='http://www.blogger.com/atom/ns#' term='DBI'/><title type='text'>MySQL LOAD DATA INFILE workaround for stored procedures</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Intro&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;     Having googled on the topic I haven't found any relevant sources suggesting a fix and here it comes. All of this was done for 5.0.x versions of MySQL that don't support LOAD DATA INFILE for some misterious security reasons (another explanation, that i've seen was it's due to the fact that stored procedures should contain valid SQL, but it doesn't really make much sense, as cursors, for example, are allowed). It was promised to return this feature in future releases, but i'm yet to try 5.1 and 5.4 to see if it's there or not. I've also read that 5.0.4b (which is beta) didn't have such problems. But let's move to the question under investigation.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;font-family:georgia;font-size:100%;"  &gt;Solution&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;As calling LOAD DATA INFILE directly from procedure is not allowed, the only option we're left with is force the procedure to tell something from outside to execute the desired LOAD DATA INFILE statement. In this post i'll show you how to do it with Perl, but it can as well be done with any other language.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;We will make a system call, that'll run a Perl script which will be passed all the necessary parameters to call LOAD DATA INFILE. For this we need 2 things:&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;1) A way to make a system call from MySQL&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;2) Perl installation (any version will do) with Perl DBI (DataBase Interface) and DBD::MySQL (DataBase Driver) modules installed&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;3) Perl script performing the job&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;So let's get to it one by one.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:georgia;font-size:100%;"  &gt;1) A way to make a system call from MySQL&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;There's no native way to perform system calls from mysql 5 (why would anyone want that anyway?!) but there's a great &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;a style="font-family: georgia;" href="http://en.wikipedia.org/wiki/User_Defined_Function"&gt;UDF&lt;/a&gt;&lt;/span&gt;&lt;span&gt; (User Defined Function) by Roland Bowman, which he posted on his &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;a style="font-family: georgia;" href="http://rpbouman.blogspot.com/2007/05/mysql-user-defined-function-repository.html"&gt;blog&lt;/a&gt;&lt;/span&gt;&lt;span&gt;, allowing you to do this. The UDFs are hosted at &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;a style="font-family: georgia;" href="http://www.mysqludf.org/"&gt;http://www.mysqludf.org/&lt;/a&gt;&lt;/span&gt;&lt;span&gt; , the one of interest for us is lib_mysqludf_sys, particularly the function sys_exec from there.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Download and unzip the archive, place the lib_mysqludf_sys.so file into your /MySQL/bin folder. If you're using Windows, like me, you'll need not the .so file, but .dll which you can build from source, or just get mine precompiled version of it (i'll post the link later).&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Then run MySQL query browser or command line tool and&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span class="code"&gt;&lt;code&gt;&lt;br /&gt;drop function if exists sys_exec;&lt;br /&gt;create function sys_exec returns int soname 'lib_mysqludf_sys.so';&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;ofcourse you'll need to change &lt;/span&gt;&lt;span style="font-size:100%;"&gt;'lib_mysqludf_sys.so' to &lt;/span&gt;&lt;span style="font-size:100%;"&gt;'lib_mysqludf_sys.dll' under Windows.&lt;br /&gt;That's it, you can now perform any command line operations right from MySQL! The usage syntax is:&lt;br /&gt;select sys_exec('command string');&lt;br /&gt;or if you don't need the output, simply&lt;br /&gt;do sys_exec('command string');&lt;br /&gt;Beware not to run any programs, that require user input, as this will hang your process. Now to test it you can, for example:&lt;br /&gt;in windows - do sys_exec('time /T &gt; time.txt');&lt;br /&gt;in unix like systems - do sys_exec('date &gt; date.txt');&lt;br /&gt;if everything works, you'll find those files in /MySQL/data/&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; Perl installation (any version will do) with Perl DBI, DBD::MySQL and DataTable modules installed&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;This is much simpler. You can get a distro of perl for your platform from from ActiveState &lt;a href="http://www.activestate.com/activeperl/"&gt;here&lt;/a&gt;. During install it's generally a good idea to allow perl to put itself to PATH. After install is complete run ppm (perl package manager), simply type ppm in command line prompt and it should run either with GUI (newer ppm versions) or in text mode. Search for DBD and DBI:MySql modules, and install them. In text mode (which you can enforce in newer ppm versions by running ppm-shell) you do:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ppm &lt;span style="font-style: italic;"&gt;(or ppm-shell)&lt;/span&gt;&lt;br /&gt;search dbi&lt;br /&gt;install *number of the module from the search results here*&lt;br /&gt;search dbd::mysql&lt;br /&gt;install *number of the module from the search results here*&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;and if you're using the graphical shell everything is self-explanatory there. Now you should be ready to rock!&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;3) Perl script performing the job&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;The script should be placed in /MySQL/data/, i called mine &lt;/span&gt;&lt;span style="font-size:100%;"&gt;LOAD_DATA_INFILE.pl&lt;/span&gt;&lt;br /&gt;Here is a sample script, allowing basic parameter handling, that issues LOAD DATA INFILE query to the database.&lt;br /&gt;&lt;br /&gt;&lt;code&gt; &lt;span style="font-size:9pt;"&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;###&lt;br /&gt;###    simply calls LOAD DATA INFILE for specified database, tablename and csv file&lt;br /&gt;###&lt;br /&gt;use DBI;&lt;br /&gt;use Getopt::Long;&lt;br /&gt;&lt;br /&gt;GetOptions( "host=s"         =&gt; \$hostname,&lt;br /&gt;        "port=i"          =&gt; \$port,&lt;br /&gt;        "username=s"    =&gt; \$username,&lt;br /&gt;        "password=s"    =&gt; \$password,&lt;br /&gt;        "database=s"    =&gt; \$database,&lt;br /&gt;        "file=s"        =&gt; \$file,&lt;br /&gt;        "table=s"        =&gt; \$table);&lt;br /&gt;&lt;br /&gt;#data file MUST be specified (plus we substitute all occurances of \ with a /)&lt;br /&gt;die "No path to *.csv file specified!!!" unless defined $file;&lt;br /&gt;die "No table name specified!!!" unless defined $table;&lt;br /&gt;$file =~ s/\\/\//g;&lt;br /&gt;&lt;br /&gt;#here we set default DB connection parameters&lt;br /&gt;if (not defined $hostname)     {$hostname = "localhost";}&lt;br /&gt;if (not defined $port)         {$port = "3306";}&lt;br /&gt;if (not defined $username)     {$username = "root";}&lt;br /&gt;if (not defined $password)     {$password = 'admin';}&lt;br /&gt;if (not defined $database)     {$database = "default_db_name";}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#connect to database&lt;br /&gt;$dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";&lt;br /&gt;$dbh = DBI-&gt;connect($dsn, $username, $password) or die("Could not connect to database '$database'!");&lt;br /&gt;&lt;br /&gt;#create and execute SQL queries&lt;br /&gt;$sql = "load data infile '$file'&lt;br /&gt;    into table $table;";&lt;br /&gt;$sth = $dbh-&gt;prepare($sql);&lt;br /&gt;$sth-&gt;execute;&lt;br /&gt;&lt;br /&gt;#disconnect from database&lt;br /&gt;$dbh-&gt;disconnect;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;this code looks pretty simple and clear, no special explanations needed.&lt;br /&gt;&lt;br /&gt;Now it's time to create a procedure, that loads something into our tables!&lt;br /&gt;&lt;code&gt;&lt;span style="font-size:9pt;"&gt;&lt;br /&gt;DELIMITER $$&lt;br /&gt;CREATE  PROCEDURE `LOAD_FILE`(file_path TEXT)&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;#CREATE TABLE table_name like some_other_table;&lt;br /&gt;&lt;br /&gt;do sys_exec(  concat('perl LOAD_DATA_INFILE.pl --table table_name --file ', file_path)  );&lt;br /&gt;&lt;br /&gt;# do something with data here&lt;br /&gt;# and maybe&lt;br /&gt;DROP TABLE if exists table_name;&lt;br /&gt;END $$&lt;br /&gt;DELIMITER ;&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;Certailnly this is not an easy way, but i couldn't find anything better on the net when i needed this a year and a half ago.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5799967069743366924-972571685372185873?l=3rdaftergod.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3rdaftergod.blogspot.com/feeds/972571685372185873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3rdaftergod.blogspot.com/2009/07/mysql-load-data-infile-workaround-for.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/972571685372185873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5799967069743366924/posts/default/972571685372185873'/><link rel='alternate' type='text/html' href='http://3rdaftergod.blogspot.com/2009/07/mysql-load-data-infile-workaround-for.html' title='MySQL LOAD DATA INFILE workaround for stored procedures'/><author><name>chhh</name><uri>http://www.blogger.com/profile/05577280816824461817</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://lh5.ggpht.com/_tv3eLQ80syw/SWKP-qY0pdI/AAAAAAAADDU/sRHJQfgAjBI/s576/IMG_0581.jpg'/></author><thr:total>2</thr:total></entry></feed>
