﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Treacle-文章分类-ROR</title><link>http://www.blogjava.net/Blake/category/1587.html</link><description>Java Toxication!</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 18:45:42 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 18:45:42 GMT</pubDate><ttl>60</ttl><item><title>Ruby Jewellery [Updating...]</title><link>http://www.blogjava.net/Blake/articles/5475.html</link><dc:creator>Blake HAN</dc:creator><author>Blake HAN</author><pubDate>Thu, 02 Jun 2005 08:37:00 GMT</pubDate><guid>http://www.blogjava.net/Blake/articles/5475.html</guid><wfw:comment>http://www.blogjava.net/Blake/comments/5475.html</wfw:comment><comments>http://www.blogjava.net/Blake/articles/5475.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Blake/comments/commentRss/5475.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Blake/services/trackbacks/5475.html</trackback:ping><description><![CDATA[<FONT face=Arial><FONT style="BACKGROUND-COLOR: #ffffff">This article will include many usefull examples. Let's enjoy Ruby!</FONT> <IMG height=19 src="http://www.blogjava.net/Emoticons/beer_mug.gif" width=19 border=0><BR><BR>
<HR>
<IMG height=20 src="http://www.blogjava.net/Emoticons/QQ/lucky.gif" width=19 border=0>&nbsp;</FONT><FONT face=Arial><FONT color=#008000><STRONG>HTTP Client<BR></STRONG></FONT>Here is am example shows how to write HTTP client with Ruby.<BR></FONT>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<DIV><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">require&nbsp;</SPAN><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">net/http'</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">def&nbsp;fetch(</SPAN><SPAN style="COLOR: #0000ff">loc</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">,&nbsp;port,&nbsp;url)<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;z</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">nil<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;h</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">Net::HTTP.</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">loc</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">,port)<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;begin<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resp,&nbsp;data&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;h.</SPAN><SPAN style="COLOR: #0000ff">get</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">(url,z)<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Code&nbsp;=&nbsp;#{resp.code}&nbsp;#{resp.message}"</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resp.</SPAN><SPAN style="COLOR: #0000ff">each</SPAN><SPAN style="COLOR: #000000">&nbsp;{|key,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">val</SPAN><SPAN style="COLOR: #000000">|&nbsp;printf&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">%-14s&nbsp;=&nbsp;%-40.40s\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;key,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">val</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">}<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;data<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;rescue&nbsp;Net::ProtoFatalError&nbsp;</SPAN><SPAN style="COLOR: #000000">=&gt;</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;detail<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;head&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;detail.data<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;head.</SPAN><SPAN style="COLOR: #0000ff">each</SPAN><SPAN style="COLOR: #000000">&nbsp;{|key,</SPAN><SPAN style="COLOR: #0000ff">val</SPAN><SPAN style="COLOR: #000000">|&nbsp;puts&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">#{key}&nbsp;&nbsp;&nbsp;&nbsp;#{val}</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">}<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;head.code</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">404"</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">File&nbsp;not&nbsp;Found"</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elsif&nbsp;head.code</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">401"</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">print</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Authorization&nbsp;Required\n&nbsp;User&nbsp;name?"</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gets<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;uname</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">$_.chomp<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">print</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Password?"</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gets<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pwd</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">$_.chomp<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unpwd</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">uname&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;pwd<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;unpwd<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hval</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">[unpwd].pack(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">m</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">)<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">Authorization'&nbsp;=&gt;&nbsp;'Basic&nbsp;'&nbsp;+&nbsp;hval}</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;retry<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;rescue&nbsp;SystemCallError<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;</FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Can't&nbsp;connect"</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><SPAN style="COLOR: #0000ff"><FONT face=Arial>end</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>fetch(</FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">www.google.com',&nbsp;80,&nbsp;'/')</SPAN></FONT></DIV></DIV><BR><BR><FONT face=Arial>
<HR>
<STRONG><FONT color=#008000><IMG height=20 src="http://www.blogjava.net/Emoticons/QQ/lucky.gif" width=19 border=0>Send email</FONT></STRONG><BR>Send email with Ruby:<BR><BR></FONT>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<DIV><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;1</SPAN>&nbsp;<SPAN style="COLOR: #000000">require&nbsp;</SPAN><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">net/smtp'</SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;2</SPAN>&nbsp;<SPAN style="COLOR: #008000"></SPAN><SPAN style="COLOR: #000000">SMTP_HOST&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">192.168.60.99"<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN>&nbsp;<SPAN style="COLOR: #000000"></SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;4</SPAN>&nbsp;<SPAN style="COLOR: #000000"></SPAN><SPAN style="COLOR: #000000">def&nbsp;send(from,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">to</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">,&nbsp;subject,&nbsp;msg)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;mail&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">To:&nbsp;#{to}\r\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;6</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">From:&nbsp;#{from}\r\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;7</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Subject:&nbsp;#{subject}\r\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;8</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\r\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;9</SPAN>&nbsp;</FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN>&nbsp;</FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">11</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;Net::SMTP.start(SMTP_HOST)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">do</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;|smtp|<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;smtp.send_mail(mail,&nbsp;from,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">to</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">14</SPAN>&nbsp;<SPAN style="COLOR: #000000"></SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">15</SPAN>&nbsp;</FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">16</SPAN>&nbsp;<SPAN style="COLOR: #000000">from&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">blake@192.168.60.99"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">17</SPAN>&nbsp;<SPAN style="COLOR: #000000"></SPAN><SPAN style="COLOR: #0000ff">to</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;[</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">blake@192.168.60.99</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">]<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN>&nbsp;<SPAN style="COLOR: #000000">send(from,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">to</SPAN><SPAN style="COLOR: #000000">,&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">test</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Just&nbsp;a&nbsp;test!\ntest</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)</SPAN></FONT></DIV></DIV><BR><FONT face=Arial><STRONG><EM><FONT color=#ff0000>Notice:</FONT></EM></STRONG><BR>1. '<STRONG>mail</STRONG>' is the email body, it use <FONT style="BACKGROUND-COLOR: #ffff00">"\r\n"</FONT> to separate the mail header and mail context. So if you only want to send context without header, you should write: "mail = "\r\n" + msg". Otherwise your email will lost the context. <BR><BR>
<HR>
<IMG height=20 src="http://www.blogjava.net/Emoticons/QQ/lucky.gif" width=19 border=0><STRONG><FONT color=#008000>Calculate the total line number of files in one folder<BR></FONT></STRONG><FONT face=Arial>This is one small tools to get the total file line number of on folder.<BR></FONT>&nbsp;
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<DIV><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">POST_FIX&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;%w{java&nbsp;jsp&nbsp;html&nbsp;xml&nbsp;properties}<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>EXCLUDE_DIR&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;%w{CVS}<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>$displayStr&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">$fileReg&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">$dirReg&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">\\.|\\.\\.|"<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">def&nbsp;sumLine(fileName)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;file&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;open&nbsp;fileName<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;begin<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">while</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;file.gets()<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"><FONT face=Arial>12</FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;ensure<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;file.close<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"><FONT face=Arial>15</FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;$.<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"><FONT face=Arial>17</FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>def&nbsp;iteDir(name,&nbsp;level</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;lines&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;dir&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;Dir.open&nbsp;name<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;rex&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">/\</SPAN><SPAN style="COLOR: #000000">.&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">java</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">$|</SPAN><SPAN style="COLOR: #000000">\</SPAN><SPAN style="COLOR: #000000">.jsp$|</SPAN><SPAN style="COLOR: #000000">\</SPAN><SPAN style="COLOR: #000000">.html$</SPAN><SPAN style="COLOR: #000000">/</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"><FONT face=Arial>22</FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;begin<BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;dir.</SPAN><SPAN style="COLOR: #0000ff">each</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">do</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;|fileName|<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fileName&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;dir.path&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">/'&nbsp;+&nbsp;fileName</SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;File.ftype(fileName)&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">~&nbsp;</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">directory</SPAN><SPAN style="COLOR: #000000">/</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">not</SPAN><SPAN style="COLOR: #000000">&nbsp;fileName&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">~&nbsp;Regexp.</SPAN><SPAN style="COLOR: #0000ff">new</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">($dirReg)<BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lines&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;iteDir(fileName,&nbsp;level</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">1</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">else</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">next</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elsif&nbsp;fileName&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">~&nbsp;Regexp.</SPAN><SPAN style="COLOR: #0000ff">new</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">($fileReg)<BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lines&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;sumLine(fileName)<BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"><FONT face=Arial>35</FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;ensure<BR></SPAN><SPAN style="COLOR: #008080">36</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;dir.close<BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;str&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">39</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">&nbsp;i&nbsp;in&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">..(level</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">1</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">40</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;str&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\t|"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">41</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">42</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;level&nbsp;!</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">43</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;str&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">---"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">44</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">45</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;$displayStr&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">#{str}#{name}\t#{lines}&nbsp;lines\n#{$displayStr}"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">46</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;&nbsp;lines<BR></SPAN><SPAN style="COLOR: #008080">47</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"><FONT face=Arial>48</FONT></SPAN><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">49</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>POST_FIX.</SPAN><SPAN style="COLOR: #0000ff">each</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">do</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;|postfix|<BR></SPAN><SPAN style="COLOR: #008080">50</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;$fileReg&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\.#{postfix}$|"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">51</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">52</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>$fileReg&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;$fileReg.chop<BR></SPAN><SPAN style="COLOR: #008080">53</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">54</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>EXCLUDE_DIR.</SPAN><SPAN style="COLOR: #0000ff">each</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">do</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;|excludeDir|<BR></SPAN><SPAN style="COLOR: #008080">55</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;$dirReg&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">^#{excludeDir}$|"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">56</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">end</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">57</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>$dirReg&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000">&nbsp;$dirReg.chop<BR></SPAN><SPAN style="COLOR: #008080">58</SPAN></FONT><FONT face=Arial><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">59</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>print&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Total&nbsp;#{iteDir(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">E:</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">_MyWorkSpace</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">IDEA_Proj</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)}&nbsp;lines\n"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT face=Arial><SPAN style="COLOR: #008080">60</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">print&nbsp;$displayStr</SPAN></FONT></DIV></DIV><BR><FONT face=Arial><STRONG><FONT color=#ff0000>Keystone:<BR></FONT></STRONG>&nbsp;&nbsp;&nbsp;1. Ruby I/O access. Dir and File<BR>&nbsp;&nbsp;&nbsp;2. Regexp &amp; String -&gt; Regexp<BR>&nbsp;&nbsp;&nbsp;3. Some kinds of variables<BR>&nbsp;&nbsp;&nbsp;4. Array operation</FONT> <BR>
<HR>
<BR></FONT>
<P><SPAN class=technoratitag>Technorati Tags: <A href="http://www.technorati.com/tags/Ruby" rel=tag>Ruby</A></SPAN> <A href="http://www.technorati.com/cosmos/search.html?rank=links&amp;url=http://www.blogjava.net/blake/articles/5475.html"><IMG src="http://www.blogjava.net/images/blogjava_net/blake/Misc/bubble_h17.gif" border=0></A> <A href="http://www.technorati.com/ping.html?url=http://www.blogjava.net/blake/articles/5475.html"><IMG alt="Ping Technorati" src="http://www.blogjava.net/images/blogjava_net/blake/Misc/refresh.gif" border=0></A></P><img src ="http://www.blogjava.net/Blake/aggbug/5475.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Blake/" target="_blank">Blake HAN</a> 2005-06-02 16:37 <a href="http://www.blogjava.net/Blake/articles/5475.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>