<?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>Shiyu Tang的财经博客 &#187; Perl</title>
	<atom:link href="http://www.shiyutang.com/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shiyutang.com</link>
	<description>有关我的投资、生活以及爱好</description>
	<lastBuildDate>Sun, 11 Dec 2011 07:41:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>A Simple Guide to Let Win32 libcurl and Perl WWW::Curl Work Together</title>
		<link>http://www.shiyutang.com/2008/07/04/a-simple-guide-to-let-win32-libcurl-and-perl-wwwcurl-work-together/</link>
		<comments>http://www.shiyutang.com/2008/07/04/a-simple-guide-to-let-win32-libcurl-and-perl-wwwcurl-work-together/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 16:59:33 +0000</pubDate>
		<dc:creator>Shiyu Tang</dc:creator>
				<category><![CDATA[开发]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.shiyutang.com/2008/07/04/a-simple-guide-to-let-win32-libcurl-and-perl-wwwcurl-work-together/</guid>
		<description><![CDATA[After several hours&#8217; work, I have finally found out how to make a compiled libcurl downloaded from cURL website and the perl module WWW::Curl work together. I hope it would be useful for you. I have already installed MinGW and ActiveState Perl 5.10. Not everyone likes to compile libcurl. It is very boring and time [...]]]></description>
			<content:encoded><![CDATA[<p>After several hours&#8217; work, I have finally found out how to make a compiled libcurl downloaded from cURL website and the perl module WWW::Curl work together. I hope it would be useful for you. I have already installed MinGW and ActiveState Perl 5.10.</p>
<p>Not everyone likes to compile libcurl. It is very boring and time comsuming. Using a compiled libcurl can save some time. So I downloaded Win32 Generic libcurl compiled by Günter Knauf from <a href="http://curl.haxx.se/download.html" target="_blank">http://curl.haxx.se/download.html</a> . The link is <a href="http://www.gknw.net/mirror/curl/win32/curl-7.18.2-devel-mingw32.zip" target="_blank">http://www.gknw.net/mirror/curl/win32/curl-7.18.2-devel-mingw32.zip</a> . I guess it is compiled by MinGW.</p>
<p>If you try to perl Makefile.PL and make, of course it would fail. So I change something in Makefile.PL.</p>
<p>1. Comment &#8220;<code>requires_external_bin       'curl-config'</code>&#8220;, that means add a &#8220;#&#8221;<br />
before the line;<br />
2. Comment <code>/usr/include</code>, <code>/usr/local/curl/include</code>, <code>/usr/local/include/curl</code>, <code>../../include</code>, <code>../curl/include</code> in &#8220;<code>my @includes</code>&#8220;;<br />
3. Change &#8220;<code>C:\\INCLUDE\\CURL</code>&#8221; in &#8220;<code>my @includes</code>&#8221; to the directory like &#8220;<code>E:\\Perldev\\downloader\\curl-7.18.2-devel-mingw32\\include</code>&#8220;. <code>E:\\Perldev\\downloader</code> is the directory where you decompress the curl-7.18.2-devel-mingw32.zip to;<br />
4. Comment &#8220;<code>my $cflags = `curl-config --cflags`</code>&#8220;, &#8220;<code>my $lflags = `curl-config --libs`</code>&#8220;, &#8220;<code>my $libcurl_version = `curl-config --version`</code>&#8221; and &#8220;<code>print "version is $libcurl_version"</code>&#8220;;<br />
5. Add these lines to the place where step 4 does:</p>
<pre>my $cflags = '-I"E:\\Perldev\\downloader\\curl-7.18.2-devel-mingw32\\include"';
my $ldflags = '-L"E:\\Perldev\\downloader\\curl-7.18.2-devel-mingw32\\lib"';
my $lflags = '-lcurl -lcurldll';</pre>
<p>6. Comment these lines:</p>
<pre>if (!defined($lflags)) {
$lflags="-lcurl";
# Windows version of libcurl - not widely tested, feedback welcome!
if ($^O eq 'MSWin32') {
foreach my $try (@includes) {
if (-f $try . '\lib\libcurl_imp.lib') {
$lflags = $try . '\lib\libcurl_imp.lib' unless(-f $lflags);
last;
}
}
$lflags="libcurl.lib" unless ($lflags);
}
print "Guessing your linker flags as: $lflags\n";
}</pre>
<p>7. At the end of this file, please change &#8220;<code>'LIBS'         =>$lflags</code>&#8221;<br />
to &#8220;<code>'LIBS'         =>"$ldflags $lflags"</code>&#8220;;<br />
8. Save the file;<br />
9. perl Makefile.PL;<br />
10. nmake (you need nmake from Mircosoft, which can be downloaded from<br />
<a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;Q132084" target="_blank">http://support.microsoft.com/default.aspx?scid=kb;en-us;Q132084</a> );<br />
11. nmake install.</p>
<p>OK, it&#8217;s done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shiyutang.com/2008/07/04/a-simple-guide-to-let-win32-libcurl-and-perl-wwwcurl-work-together/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>在Perl中使用UTF-8编码查询MySQL数据库</title>
		<link>http://www.shiyutang.com/2008/06/18/%e5%9c%a8perl%e4%b8%ad%e4%bd%bf%e7%94%a8utf-8%e7%bc%96%e7%a0%81%e6%9f%a5%e8%af%a2mysql%e6%95%b0%e6%8d%ae%e5%ba%93/</link>
		<comments>http://www.shiyutang.com/2008/06/18/%e5%9c%a8perl%e4%b8%ad%e4%bd%bf%e7%94%a8utf-8%e7%bc%96%e7%a0%81%e6%9f%a5%e8%af%a2mysql%e6%95%b0%e6%8d%ae%e5%ba%93/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 04:45:06 +0000</pubDate>
		<dc:creator>Shiyu Tang</dc:creator>
				<category><![CDATA[开发]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://www.shiyutang.com/2008/06/18/%e5%9c%a8perl%e4%b8%ad%e4%bd%bf%e7%94%a8utf-8%e7%bc%96%e7%a0%81%e6%9f%a5%e8%af%a2mysql%e6%95%b0%e6%8d%ae%e5%ba%93/</guid>
		<description><![CDATA[Perl里提供了DBI这个模块来连接MySQL数据库，使得查询MySQL数据库特别方便。不过，很多人发现，如果MySQL数据库的某些表中使用了UTF-8编码，那查询的结果就成了“？”，为此不得不采用GB2312这样的编码。实际上，这个问题解决起来也很简单，就是在连接字段里面加上{&#8216;mysql_enable_utf8&#8242;=&#62;1}即可。例如下面的一小段示范代码： use DBI; use warnings; use strict; use utf8; use bytes; my $dbh = DBI-&#62;connect("DBI:mysql:database=yourdatabase;host=yourhost", "username", "password", {'RaiseError'=&#62;1, 'mysql_enable_utf8'=&#62;1}) &#124;&#124; die "Cannot connect to database:".DBI-&#62;errstr; my $sth=$dbh-&#62;prepare('SELECT * FROM onetable'); $sth-&#62;execute()&#124;&#124;die "An error occurs while querying: ".$sth-&#62;errstr; while(my @data=$sth-&#62;fetchrow_array()){ for my $i(0..$#data) { print "$data[$i]\\t"; } print "\\n"; } $dbh-&#62;disconnect();]]></description>
			<content:encoded><![CDATA[<p>Perl里提供了DBI这个模块来连接MySQL数据库，使得查询MySQL数据库特别方便。不过，很多人发现，如果MySQL数据库的某些表中使用了UTF-8编码，那查询的结果就成了“？”，为此不得不采用GB2312这样的编码。实际上，这个问题解决起来也很简单，就是在连接字段里面加上{&#8216;mysql_enable_utf8&#8242;=&gt;1}即可。例如下面的一小段示范代码：</p>
<pre>
use DBI;
use warnings;
use strict;
use utf8;
use bytes;

my $dbh = DBI-&gt;connect("DBI:mysql:database=yourdatabase;host=yourhost",
			"username", "password",
			{'RaiseError'=&gt;1, 'mysql_enable_utf8'=&gt;1})
			|| die "Cannot connect to database:".DBI-&gt;errstr;
my $sth=$dbh-&gt;prepare('SELECT * FROM onetable');
$sth-&gt;execute()||die "An error occurs while querying: ".$sth-&gt;errstr;
while(my @data=$sth-&gt;fetchrow_array()){
	for my $i(0..$#data) {
		print "$data[$i]\\t";
	}
	print "\\n";
}
$dbh-&gt;disconnect();</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shiyutang.com/2008/06/18/%e5%9c%a8perl%e4%b8%ad%e4%bd%bf%e7%94%a8utf-8%e7%bc%96%e7%a0%81%e6%9f%a5%e8%af%a2mysql%e6%95%b0%e6%8d%ae%e5%ba%93/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在Perl的Mason模块中使用UTF-8编码</title>
		<link>http://www.shiyutang.com/2008/06/16/%e5%9c%a8perl%e7%9a%84mason%e6%a8%a1%e5%9d%97%e4%b8%ad%e4%bd%bf%e7%94%a8utf-8%e7%bc%96%e7%a0%81/</link>
		<comments>http://www.shiyutang.com/2008/06/16/%e5%9c%a8perl%e7%9a%84mason%e6%a8%a1%e5%9d%97%e4%b8%ad%e4%bd%bf%e7%94%a8utf-8%e7%bc%96%e7%a0%81/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 12:20:30 +0000</pubDate>
		<dc:creator>Shiyu Tang</dc:creator>
				<category><![CDATA[开发]]></category>
		<category><![CDATA[Mason]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://www.shiyutang.com/2008/06/16/%e5%9c%a8perl%e7%9a%84mason%e6%a8%a1%e5%9d%97%e4%b8%ad%e4%bd%bf%e7%94%a8utf-8%e7%bc%96%e7%a0%81/</guid>
		<description><![CDATA[使用Perl做网站的人都喜欢用Mason，因为它可以使Perl像PHP那样，而不是print一大堆html标签。不过默认情况下，它使用UTF-8编码时，输出的网页是乱码。其实这个问题解决起来也很简单，就是在你的网页的最前面加上一行： % $r-&#62;content_type('text/html; charset=UTF-8'); 就可以了。 例如这是个最简单的index.html文件： % $r-&#62;content_type('text/html; charset=UTF-8'); % my $planet = "世界"; 你好，&#60;% $planet %&#62;！]]></description>
			<content:encoded><![CDATA[<p>使用Perl做网站的人都喜欢用Mason，因为它可以使Perl像PHP那样，而不是print一大堆html标签。不过默认情况下，它使用UTF-8编码时，输出的网页是乱码。其实这个问题解决起来也很简单，就是在你的网页的最前面加上一行：</p>
<pre>% $r-&gt;content_type('text/html; charset=UTF-8');</pre>
<p>就可以了。</p>
<p>例如这是个最简单的index.html文件：<br />
<code>% $r-&gt;content_type('text/html; charset=UTF-8');<br />
% my $planet = "世界";<br />
你好，&lt;% $planet %&gt;！</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shiyutang.com/2008/06/16/%e5%9c%a8perl%e7%9a%84mason%e6%a8%a1%e5%9d%97%e4%b8%ad%e4%bd%bf%e7%94%a8utf-8%e7%bc%96%e7%a0%81/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

