<?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>张经纬的博客 &#187; Perl</title>
	<atom:link href="http://www.zhangjingwei.com/archives/category/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zhangjingwei.com</link>
	<description>中隐留司官</description>
	<lastBuildDate>Wed, 08 Sep 2010 17:36:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Luhn 算法的Perl实现</title>
		<link>http://www.zhangjingwei.com/archives/perl-luhn/</link>
		<comments>http://www.zhangjingwei.com/archives/perl-luhn/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 17:09:32 +0000</pubDate>
		<dc:creator>张经纬</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Luhn]]></category>

		<guid isPermaLink="false">http://www.zhangjingwei.com/?p=1341</guid>
		<description><![CDATA[Luhn 算法主要应用在校键数字卡号的合法性，例如我们常见的银行卡，信用卡，ICCID号等等。 Luhn 算法简单的说，既从低位开始，基数位相加的和，与处理过的（将当前偶数位数字×2，若结果大于9，则将2位数字相加得到个位数，若结果小于等于9，直接记录这个值）偶数位相加的和的总和，若可被10整除，则合法，反之则不合法。 算法如下： #!/usr/bin/perl use strict; use warnings; &#160; #定义一个卡号 my $cardNum = &#34;4367421590502289184&#34;; &#160; sub luhnCheckNum&#123; my $oddSum = 0; my $evenSum = 0; my $isOdd = 1; for&#40;my $i=length&#40;$_&#91;0&#93;&#41;-1; $i&#62;=0; $i--&#41;&#123; my $iNum = substr&#40;$_&#91;0&#93;,$i,1&#41;; if&#40;$isOdd&#41;&#123; $oddSum += $iNum; &#125;else&#123; $iNum = $iNum*2; if&#40;$iNum&#62;9&#41;&#123; my @iNumArry = split&#40;//, $iNum&#41;; $iNum = [...]]]></description>
			<content:encoded><![CDATA[<p>Luhn 算法主要应用在校键数字卡号的合法性，例如我们常见的银行卡，信用卡，ICCID号等等。</p>
<p>Luhn 算法简单的说，既从低位开始，基数位相加的和，与处理过的（将当前偶数位数字×2，若结果大于9，则将2位数字相加得到个位数，若结果小于等于9，直接记录这个值）偶数位相加的和的总和，若可被10整除，则合法，反之则不合法。</p>
<p>算法如下：</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#定义一个卡号</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cardNum</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;4367421590502289184&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> luhnCheckNum<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$oddSum</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$evenSum</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$isOdd</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">=</span><span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">&gt;=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$iNum</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$i</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$isOdd</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #0000ff;">$oddSum</span> <span style="color: #339933;">+=</span> <span style="color: #0000ff;">$iNum</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
			<span style="color: #0000ff;">$iNum</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$iNum</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$iNum</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@iNumArry</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">//,</span> <span style="color: #0000ff;">$iNum</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #0000ff;">$iNum</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$iNumArry</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">$iNumArry</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #0000ff;">$evenSum</span> <span style="color: #339933;">+=</span> <span style="color: #0000ff;">$iNum</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #0000ff;">$isOdd</span> <span style="color: #339933;">=</span> <span style="color: #339933;">!</span><span style="color: #0000ff;">$isOdd</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$evenSum</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$oddSum</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span>10<span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>luhnCheckNum<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$cardNum</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;您输入卡号合法&quot;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;您输入的卡号不合法&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




加入书签:


	<a rel="nofollow" class="thickbox" href="http://shuqian.qq.com/post?jumpback=1&title=Luhn%20%E7%AE%97%E6%B3%95%E7%9A%84Perl%E5%AE%9E%E7%8E%B0&uri=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-luhn%2F?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/qq.png" title="QQ书签" alt="QQ书签" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-luhn%2F&title=Luhn%20%E7%AE%97%E6%B3%95%E7%9A%84Perl%E5%AE%9E%E7%8E%B0?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/douban.png" title="豆瓣" alt="豆瓣" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-luhn%2F&title=Luhn%20%E7%AE%97%E6%B3%95%E7%9A%84Perl%E5%AE%9E%E7%8E%B0&n=1?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/douban9.png" title="豆瓣九点" alt="豆瓣九点" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.haohaoreport.com/submit.php?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-luhn%2F&amp;title=Luhn%20%E7%AE%97%E6%B3%95%E7%9A%84Perl%E5%AE%9E%E7%8E%B0?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/haohao.png" title="Haohao" alt="Haohao" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.zhangjingwei.com/feed/?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Luhn%20%E7%AE%97%E6%B3%95%E7%9A%84Perl%E5%AE%9E%E7%8E%B0&amp;body=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-luhn%2F" title="email"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.zhangjingwei.com/archives/perl-luhn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl 压缩 Js</title>
		<link>http://www.zhangjingwei.com/archives/perl-compression-js/</link>
		<comments>http://www.zhangjingwei.com/archives/perl-compression-js/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 10:54:09 +0000</pubDate>
		<dc:creator>张经纬</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[正则]]></category>

		<guid isPermaLink="false">http://www.zhangjingwei.com/?p=1335</guid>
		<description><![CDATA[sub compress &#123; my &#40;$codevalue&#41;=@_; $codevalue =~ s/不支持Flash//; $codevalue =~ s/^\s+//; $codevalue =~ s/&#60;!--(.*?)--&#62;//g; $codevalue =~ s/(http&#124;https):\/\//$1:~~/g; $codevalue =~ s/\s*\/\/.*?\n/\n/g; $codevalue =~ s/(http&#124;https):~~/$1:\/\//g; $codevalue =~ s/(^&#124; &#124;\t)\/\/.*$//g; $codevalue =~ s!/\*.*?\*/\s*!!sg; $codevalue =~ s/(;&#124;\n)\t+/$1/g; $codevalue =~ s/\n{2,}/\n/g; $codevalue =~ s/(if&#124;else)\s*(\(.*?\))?\s*([\w\{])/$1$2$3/sg; $codevalue =~ s/[ \t]*([\=\,\+\-\*\&#38;\&#124;\:\?\&#60; \&#62;\{\}\(\)\[\]]+)[ \t]*/$1/g; $codevalue =~ s/^\s*\n//mg; $codevalue =~ s/(;)\s*/$1/g; $codevalue =~ s/(\r\n&#124;\n)//g; $codevalue [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">sub</span> compress <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$codevalue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/不支持Flash//</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^\s+//</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/&lt;!--(.*?)--&gt;//g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/(http|https):\/\//$1:~~/g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\s*\/\/.*?\n/\n/g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/(http|https):~~/$1:\/\//g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/(^| |\t)\/\/.*$//g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #000066;">s</span><span style="color: #339933;">!/</span>\<span style="color: #339933;">*.*?</span>\<span style="color: #339933;">*/</span><span style="color: #0000ff;">\s</span><span style="color: #339933;">*!!</span>sg<span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/(;|\n)\t+/$1/g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\n{2,}/\n/g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/(if|else)\s*(\(.*?\))?\s*([\w\{])/$1$2$3/sg</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/[ \t]*([\=\,\+\-\*\&amp;\|\:\?\&lt; \&gt;\{\}\(\)\[\]]+)[ \t]*/$1/g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^\s*\n//mg</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/(;)\s*/$1/g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/(\r\n|\n)//g</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$codevalue</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/({)(\s*?)(\S)/$1$3/g</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">return</span> <span style="color: #0000ff;">$codevalue</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>




加入书签:


	<a rel="nofollow" class="thickbox" href="http://shuqian.qq.com/post?jumpback=1&title=Perl%20%E5%8E%8B%E7%BC%A9%20Js&uri=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-compression-js%2F?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/qq.png" title="QQ书签" alt="QQ书签" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-compression-js%2F&title=Perl%20%E5%8E%8B%E7%BC%A9%20Js?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/douban.png" title="豆瓣" alt="豆瓣" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-compression-js%2F&title=Perl%20%E5%8E%8B%E7%BC%A9%20Js&n=1?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/douban9.png" title="豆瓣九点" alt="豆瓣九点" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.haohaoreport.com/submit.php?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-compression-js%2F&amp;title=Perl%20%E5%8E%8B%E7%BC%A9%20Js?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/haohao.png" title="Haohao" alt="Haohao" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.zhangjingwei.com/feed/?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Perl%20%E5%8E%8B%E7%BC%A9%20Js&amp;body=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2Fperl-compression-js%2F" title="email"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.zhangjingwei.com/archives/perl-compression-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>读取数据库查询结果条数</title>
		<link>http://www.zhangjingwei.com/archives/%e8%af%bb%e5%8f%96%e6%95%b0%e6%8d%ae%e5%ba%93%e6%9f%a5%e8%af%a2%e7%bb%93%e6%9e%9c%e6%9d%a1%e6%95%b0/</link>
		<comments>http://www.zhangjingwei.com/archives/%e8%af%bb%e5%8f%96%e6%95%b0%e6%8d%ae%e5%ba%93%e6%9f%a5%e8%af%a2%e7%bb%93%e6%9e%9c%e6%9d%a1%e6%95%b0/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 04:07:35 +0000</pubDate>
		<dc:creator>张经纬</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.zhangjingwei.com/?p=1230</guid>
		<description><![CDATA[使用perl查询数据库后，用如下方法读取数据库查询结果条数。 my $sth=&#38;execsql&#40;$dbh,&#34;select * from DB&#34;&#41;; my $rc = $sth-&#62;rows; print $rc; 加入书签:]]></description>
			<content:encoded><![CDATA[<p>使用perl查询数据库后，用如下方法读取数据库查询结果条数。</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&amp;execsql</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dbh</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;select * from DB&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$rc</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">rows</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #0000ff;">$rc</span><span style="color: #339933;">;</span></pre></div></div>




加入书签:


	<a rel="nofollow" class="thickbox" href="http://shuqian.qq.com/post?jumpback=1&title=%E8%AF%BB%E5%8F%96%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E8%AF%A2%E7%BB%93%E6%9E%9C%E6%9D%A1%E6%95%B0&uri=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e8%25af%25bb%25e5%258f%2596%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593%25e6%259f%25a5%25e8%25af%25a2%25e7%25bb%2593%25e6%259e%259c%25e6%259d%25a1%25e6%2595%25b0%2F?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/qq.png" title="QQ书签" alt="QQ书签" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e8%25af%25bb%25e5%258f%2596%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593%25e6%259f%25a5%25e8%25af%25a2%25e7%25bb%2593%25e6%259e%259c%25e6%259d%25a1%25e6%2595%25b0%2F&title=%E8%AF%BB%E5%8F%96%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E8%AF%A2%E7%BB%93%E6%9E%9C%E6%9D%A1%E6%95%B0?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/douban.png" title="豆瓣" alt="豆瓣" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e8%25af%25bb%25e5%258f%2596%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593%25e6%259f%25a5%25e8%25af%25a2%25e7%25bb%2593%25e6%259e%259c%25e6%259d%25a1%25e6%2595%25b0%2F&title=%E8%AF%BB%E5%8F%96%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E8%AF%A2%E7%BB%93%E6%9E%9C%E6%9D%A1%E6%95%B0&n=1?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/douban9.png" title="豆瓣九点" alt="豆瓣九点" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.haohaoreport.com/submit.php?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e8%25af%25bb%25e5%258f%2596%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593%25e6%259f%25a5%25e8%25af%25a2%25e7%25bb%2593%25e6%259e%259c%25e6%259d%25a1%25e6%2595%25b0%2F&amp;title=%E8%AF%BB%E5%8F%96%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E8%AF%A2%E7%BB%93%E6%9E%9C%E6%9D%A1%E6%95%B0?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/haohao.png" title="Haohao" alt="Haohao" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.zhangjingwei.com/feed/?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=%E8%AF%BB%E5%8F%96%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E8%AF%A2%E7%BB%93%E6%9E%9C%E6%9D%A1%E6%95%B0&amp;body=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e8%25af%25bb%25e5%258f%2596%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593%25e6%259f%25a5%25e8%25af%25a2%25e7%25bb%2593%25e6%259e%259c%25e6%259d%25a1%25e6%2595%25b0%2F" title="email"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.zhangjingwei.com/archives/%e8%af%bb%e5%8f%96%e6%95%b0%e6%8d%ae%e5%ba%93%e6%9f%a5%e8%af%a2%e7%bb%93%e6%9e%9c%e6%9d%a1%e6%95%b0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>标量转数组</title>
		<link>http://www.zhangjingwei.com/archives/%e6%a0%87%e9%87%8f%e8%bd%ac%e6%95%b0%e7%bb%84/</link>
		<comments>http://www.zhangjingwei.com/archives/%e6%a0%87%e9%87%8f%e8%bd%ac%e6%95%b0%e7%bb%84/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 10:42:51 +0000</pubDate>
		<dc:creator>张经纬</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.zhangjingwei.com/?p=1223</guid>
		<description><![CDATA[#标量转数组 $ckVal = '标-量-转-数-组-函-数'; $pattern='-'; @categories = split&#40;/-/, $ckVal&#41;; 利用split函数将标量分割后压入数组。既可用$ary[index]，取得对应的值。 加入书签:]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#标量转数组</span>
<span style="color: #0000ff;">$ckVal</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'标-量-转-数-组-函-数'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$pattern</span><span style="color: #339933;">=</span><span style="color: #ff0000;">'-'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">@categories</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/-/</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ckVal</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>利用split函数将标量分割后压入数组。既可用$ary[index]，取得对应的值。</p>



加入书签:


	<a rel="nofollow" class="thickbox" href="http://shuqian.qq.com/post?jumpback=1&title=%E6%A0%87%E9%87%8F%E8%BD%AC%E6%95%B0%E7%BB%84&uri=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e6%25a0%2587%25e9%2587%258f%25e8%25bd%25ac%25e6%2595%25b0%25e7%25bb%2584%2F?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/qq.png" title="QQ书签" alt="QQ书签" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e6%25a0%2587%25e9%2587%258f%25e8%25bd%25ac%25e6%2595%25b0%25e7%25bb%2584%2F&title=%E6%A0%87%E9%87%8F%E8%BD%AC%E6%95%B0%E7%BB%84?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/douban.png" title="豆瓣" alt="豆瓣" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e6%25a0%2587%25e9%2587%258f%25e8%25bd%25ac%25e6%2595%25b0%25e7%25bb%2584%2F&title=%E6%A0%87%E9%87%8F%E8%BD%AC%E6%95%B0%E7%BB%84&n=1?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/douban9.png" title="豆瓣九点" alt="豆瓣九点" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.haohaoreport.com/submit.php?url=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e6%25a0%2587%25e9%2587%258f%25e8%25bd%25ac%25e6%2595%25b0%25e7%25bb%2584%2F&amp;title=%E6%A0%87%E9%87%8F%E8%BD%AC%E6%95%B0%E7%BB%84?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/haohao.png" title="Haohao" alt="Haohao" class="sociable-hovers" /></a>
	<a rel="nofollow" class="thickbox" href="http://www.zhangjingwei.com/feed/?TB_iframe=true&amp;height=500&amp;width=900"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=%E6%A0%87%E9%87%8F%E8%BD%AC%E6%95%B0%E7%BB%84&amp;body=http%3A%2F%2Fwww.zhangjingwei.com%2Farchives%2F%25e6%25a0%2587%25e9%2587%258f%25e8%25bd%25ac%25e6%2595%25b0%25e7%25bb%2584%2F" title="email"><img src="http://www.zhangjingwei.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.zhangjingwei.com/archives/%e6%a0%87%e9%87%8f%e8%bd%ac%e6%95%b0%e7%bb%84/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
