锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲第一页综合图片自拍,久99精品视频在线观看婷亚洲片国产一区一级在线 ,亚洲美女在线国产http://www.tkk7.com/persister/category/37147.htmlzh-cnThu, 09 Sep 2010 04:41:43 GMTThu, 09 Sep 2010 04:41:43 GMT60Perl瀛︿範(fàn)鍏紙緇冧範(fàn)棰橈級(jí)http://www.tkk7.com/persister/archive/2009/09/15/295141.htmlpersisterpersisterTue, 15 Sep 2009 06:16:00 GMThttp://www.tkk7.com/persister/archive/2009/09/15/295141.htmlhttp://www.tkk7.com/persister/comments/295141.htmlhttp://www.tkk7.com/persister/archive/2009/09/15/295141.html#Feedback0http://www.tkk7.com/persister/comments/commentRss/295141.htmlhttp://www.tkk7.com/persister/services/trackbacks/295141.html
1 # !/usr/bin/perl -w
      2
      
3 @list = <STDIN>;
      
4 @list = sort(@list);
      
5 @list = reverse @list;
      
6
      
7 print "\n";
      
8
      
9 print @list;
     
10
     
11 print "\n";
     
12 print "input the number:\n";
     
13 $num = <STDIN>;
     
14 print $list[$num];
     
15 srand;
     16 print $list[rand(@list)];

鍙戠幇絎洓琛?@list[$num]鐨勭粨鏋滀篃鏄竴鏍風(fēng)殑錛屼笉蹇呮槸$list[$num]錛岄毦閬撴槸鐗堟湰闂錛?br /> 涔︿笂璇磗rand鏄繘琛岄殢鏈烘暟鍒濆鍖栫殑錛屼絾鏄彂鐜板鏋滃垹闄よ繖琛屼篃鍙互



persister 2009-09-15 14:16 鍙戣〃璇勮
]]>
Perl瀛︿範(fàn)絎旇浜?/title><link>http://www.tkk7.com/persister/archive/2009/09/14/295074.html</link><dc:creator>persister</dc:creator><author>persister</author><pubDate>Mon, 14 Sep 2009 14:10:00 GMT</pubDate><guid>http://www.tkk7.com/persister/archive/2009/09/14/295074.html</guid><wfw:comment>http://www.tkk7.com/persister/comments/295074.html</wfw:comment><comments>http://www.tkk7.com/persister/archive/2009/09/14/295074.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/persister/comments/commentRss/295074.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/persister/services/trackbacks/295074.html</trackback:ping><description><![CDATA[1.The -x File Tests<br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">where? </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">2</span> <span style="color: #800080;">$filename</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;"><</span><span style="color: #000000;">STDIN</span><span style="color: #000000;">></span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">3</span> <span style="color: #0000ff;">chomp</span><span style="color: #000000;"> </span><span style="color: #800080;">$filename</span><span style="color: #000000;">; </span><span style="color: #008000;">#</span><span style="color: #008000;"> toss pesky newline</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">4</span> <span style="color: #0000ff;">if</span><span style="color: #000000;"> (</span><span style="color: #000000;">-</span><span style="color: #000000;">r </span><span style="color: #800080;">$filename</span><span style="color: #000000;"> </span><span style="color: #000000;">&&</span><span style="color: #000000;"> </span><span style="color: #000000;">-</span><span style="color: #000000;">w </span><span style="color: #800080;">$filename</span><span style="color: #000000;">) {<br /> </span><span style="color: #008080;">5</span> <span style="color: #008000;">#</span><span style="color: #008000;"> file exists, and I can read and write it</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">6</span> <span style="color: #000000;"><img src="http://www.tkk7.com/Images/dot.gif" alt="" /></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">7</span> <span style="color: #000000;">}</span></div> <br /> Table 10.1: File Tests and Their Meanings<br /> File Test Meaning<br /> -r File or directory is readable<br /> -w File or directory is writable<br /> -x File or directory is executable<br /> -o File or directory is owned by user<br /> -R File or directory is readable by real user, not effective user (differs from -r for setuid<br /> programs)<br /> -W File or directory is writable by real user, not effective user (differs from -w for setuid<br /> programs)<br /> -X File or directory is executable by real user, not effective user (differs from -x for setuid<br /> programs)<br /> -O File or directory is owned by real user, not effective user (differs from -o for setuid<br /> programs)<br /> -e File or directory exists<br /> -z File exists and has zero size (directories are never empty)<br /> -s File or directory exists and has nonzero size (the value is the size in bytes)<br /> -f Entry is a plain file<br /> -d Entry is a directory<br /> -l Entry is a symlink<br /> -S Entry is a socket<br /> -p Entry is a named pipe (a "fifo")<br /> -b Entry is a block-special file (like a mountable disk)<br /> -c Entry is a character-special file (like an I/O device)<br /> -u File or directory is setuid<br /> -g File or directory is setgid<br /> -k File or directory has the sticky bit set<br /> -t isatty() on the filehandle is true<br /> -T File is "text"<br /> -B File is "binary"<br /> -M Modification age in days<br /> -A Access age in days<br /> -C Inode-modification age in days<br /> <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #0000ff;">foreach</span><span style="color: #000000;"> (</span><span style="color: #800080;">@some_list_of_filenames</span><span style="color: #000000;">) {<br /> </span><span style="color: #008080;">2</span> <span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">$_ is readable\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> </span><span style="color: #000000;">-</span><span style="color: #000000;">r; </span><span style="color: #008000;">#</span><span style="color: #008000;"> same as -r $_</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">3</span> <span style="color: #000000;">}</span></div> <br /> 2.The stat and lstat Functions<br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #000000;">(</span><span style="color: #800080;">$dev</span><span style="color: #000000;">,</span><span style="color: #800080;">$ino</span><span style="color: #000000;">,</span><span style="color: #800080;">$mode</span><span style="color: #000000;">,</span><span style="color: #800080;">$nlink</span><span style="color: #000000;">,</span><span style="color: #800080;">$uid</span><span style="color: #000000;">,</span><span style="color: #800080;">$gid</span><span style="color: #000000;">,</span><span style="color: #800080;">$rdev</span><span style="color: #000000;">,</span><span style="color: #000000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #800080;">$size</span><span style="color: #000000;">,</span><span style="color: #800080;">$atime</span><span style="color: #000000;">,</span><span style="color: #800080;">$mtime</span><span style="color: #000000;">,</span><span style="color: #800080;">$ctime</span><span style="color: #000000;">,</span><span style="color: #800080;">$blksize</span><span style="color: #000000;">,</span><span style="color: #800080;">$blocks</span><span style="color: #000000;">) </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">stat</span><span style="color: #000000;">(</span><span style="color: #000000;"><img src="http://www.tkk7.com/Images/dot.gif" alt="" /></span><span style="color: #000000;">)</span></div> <br /> <img src ="http://www.tkk7.com/persister/aggbug/295074.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/persister/" target="_blank">persister</a> 2009-09-14 22:10 <a href="http://www.tkk7.com/persister/archive/2009/09/14/295074.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Perl瀛︿範(fàn)絎旇鍥?/title><link>http://www.tkk7.com/persister/archive/2009/09/11/294737.html</link><dc:creator>persister</dc:creator><author>persister</author><pubDate>Fri, 11 Sep 2009 07:23:00 GMT</pubDate><guid>http://www.tkk7.com/persister/archive/2009/09/11/294737.html</guid><wfw:comment>http://www.tkk7.com/persister/comments/294737.html</wfw:comment><comments>http://www.tkk7.com/persister/archive/2009/09/11/294737.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/persister/comments/commentRss/294737.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/persister/services/trackbacks/294737.html</trackback:ping><description><![CDATA[1. subroutine<br />    <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #0000ff;">sub</span><span style="color: #000000;"> say {<br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;">       </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">$_[0], $_[1]!</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">;<br /> </span><span style="color: #008080;">3</span> <span style="color: #000000; font-weight: bold;">   }<br /> </span><span style="color: #008080;">4</span> <span style="color: #000000; font-weight: bold;">   say(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">hello</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">,</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">world</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">); # hello world, once again<br /> </span><span style="color: #008080;">5</span> <span style="color: #000000; font-weight: bold;">   say(</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">goodbye</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">,</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">cruel world</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">); # silent movie lament<br /> </span><span style="color: #008080;">6</span> </div> 2.Private Variables in Functions<br />   <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;"> 1</span> <span style="color: #0000ff;">sub</span><span style="color: #000000;"> bigger_than {<br /> </span><span style="color: #008080;"> 2</span> <span style="color: #000000;">    </span><span style="color: #0000ff;">my</span><span style="color: #000000;">(</span><span style="color: #800080;">$n</span><span style="color: #000000;">,</span><span style="color: #800080;">@values</span><span style="color: #000000;">); </span><span style="color: #008000;">#</span><span style="color: #008000;"> create some local variables</span><span style="color: #008000;"><br /> </span><span style="color: #008080;"> 3</span> <span style="color: #000000;">    (</span><span style="color: #800080;">$n</span><span style="color: #000000;">,</span><span style="color: #800080;">@values</span><span style="color: #000000;">) </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">@_</span><span style="color: #000000;">; </span><span style="color: #008000;">#</span><span style="color: #008000;"> split args into limit and values</span><span style="color: #008000;"><br /> </span><span style="color: #008080;"> 4</span> <span style="color: #000000;">    </span><span style="color: #0000ff;">my</span><span style="color: #000000;">(</span><span style="color: #800080;">@result</span><span style="color: #000000;">); </span><span style="color: #008000;">#</span><span style="color: #008000;"> temporary for holding the return value</span><span style="color: #008000;"><br /> </span><span style="color: #008080;"> 5</span> <span style="color: #000000;">    </span><span style="color: #0000ff;">foreach</span><span style="color: #000000;"> </span><span style="color: #800080;">$_</span><span style="color: #000000;"> (</span><span style="color: #800080;">@values</span><span style="color: #000000;">) { </span><span style="color: #008000;">#</span><span style="color: #008000;"> step through the arg list</span><span style="color: #008000;"><br /> </span><span style="color: #008080;"> 6</span> <span style="color: #000000;">      </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (</span><span style="color: #800080;">$_</span><span style="color: #000000;"> </span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #800080;">$n</span><span style="color: #000000;">) { </span><span style="color: #008000;">#</span><span style="color: #008000;"> is it eligible?</span><span style="color: #008000;"><br /> </span><span style="color: #008080;"> 7</span> <span style="color: #000000;">       </span><span style="color: #0000ff;">push</span><span style="color: #000000;">(</span><span style="color: #800080;">@result</span><span style="color: #000000;">,</span><span style="color: #800080;">$_</span><span style="color: #000000;">); </span><span style="color: #008000;">#</span><span style="color: #008000;"> add it</span><span style="color: #008000;"><br /> </span><span style="color: #008080;"> 8</span> <span style="color: #000000;">      }<br /> </span><span style="color: #008080;"> 9</span> <span style="color: #000000;">    }<br /> </span><span style="color: #008080;">10</span> <span style="color: #000000;">    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #800080;">@result</span><span style="color: #000000;">; </span><span style="color: #008000;">#</span><span style="color: #008000;"> return the final list</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">11</span> <span style="color: #000000;">  }</span></div> # some invocations:<br /> @this = bigger_than(5,1,5,15,30); # @this gets (15,30)<br /> <br /> 3.File-Level my( ) Variables<br />   The my() operator can also be used at the outermost level of your program, outside of <br />   any subroutines or blocks. While this isn't really a "local" variable in the sense <br />   defined above, it's actually rather useful,especially when used in conjunction with a <br />   Perl pragma:<br />     use strict;<br />   A pragma is a compiler directive. Other directives include those to set up integer<br />   arithmetic, overload numeric operators, or request more verbose warnings and error<br />   messages. <br />   If you place this pragma at the beginning of your file, you will no longer be able <br />   to use variables (scalars,arrays, and hashes) until you have first "declared" them. <br />   And you declare them with my(), like so:<br />   <br />   <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #0000ff;">use</span><span style="color: #000000;"> strict;<br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;">  </span><span style="color: #0000ff;">my</span><span style="color: #000000;"> </span><span style="color: #800080;">$a</span><span style="color: #000000;">; </span><span style="color: #008000;">#</span><span style="color: #008000;"> starts as undef</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">3</span> <span style="color: #000000;">  </span><span style="color: #0000ff;">my</span><span style="color: #000000;"> </span><span style="color: #800080;">@b</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> qw(fred barney betty); </span><span style="color: #008000;">#</span><span style="color: #008000;"> give initial value</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">4</span> <span style="color: #000000;">  </span><span style="color: #000000;"><img src="http://www.tkk7.com/Images/dot.gif" alt="" /></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">5</span> <span style="color: #000000;">  </span><span style="color: #0000ff;">push</span><span style="color: #000000;"> </span><span style="color: #800080;">@b</span><span style="color: #000000;">,</span><span style="color: #000000;"> qw(wilma); </span><span style="color: #008000;">#</span><span style="color: #008000;"> cannot leave her out</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">6</span> <span style="color: #000000;">  </span><span style="color: #800080;">@c</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">sort</span><span style="color: #000000;"> </span><span style="color: #800080;">@b</span><span style="color: #000000;">; </span><span style="color: #008000;">#</span><span style="color: #008000;"> WILL NOT COMPILE</span></div> <br />   That last statement will be flagged at compile time as an error, because it referred <br />   to a variable that had not previously been declared with my (that is, @c). In other <br />   words,your program won't even start running unless every single variable being used <br />   has been declared. The advantages of forcing variable declarations are twofold:<br />   1.  Your programs will run slightly faster (variables created with my are accessed <br />   slightly faster than ordinary variables).<br />   <br />   Variables created with my() are not found in any package.<br />   2. You'll catch mistakes in typing much faster, because you'll no longer be able <br />      to accidentally reference a nonexisting variable named $freed when you wanted $fred.<br /> <br /> 4.The last Statement<br />   <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;"> 1</span> <span style="color: #0000ff;">while</span><span style="color: #000000;"> (something) {<br /> </span><span style="color: #008080;"> 2</span> <span style="color: #000000;">      something;<br /> </span><span style="color: #008080;"> 3</span> <span style="color: #000000;">      something;<br /> </span><span style="color: #008080;"> 4</span> <span style="color: #000000;">      something;<br /> </span><span style="color: #008080;"> 5</span> <span style="color: #000000;">      </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (somecondition) {<br /> </span><span style="color: #008080;"> 6</span> <span style="color: #000000;">         somethingorother;<br /> </span><span style="color: #008080;"> 7</span> <span style="color: #000000;">         somethingorother;<br /> </span><span style="color: #008080;"> 8</span> <span style="color: #000000;">         </span><span style="color: #0000ff;">last</span><span style="color: #000000;">; </span><span style="color: #008000;">#</span><span style="color: #008000;"> break out of the while loop</span><span style="color: #008000;"><br /> </span><span style="color: #008080;"> 9</span> <span style="color: #000000;">      }<br /> </span><span style="color: #008080;">10</span> <span style="color: #000000;">      morethings;<br /> </span><span style="color: #008080;">11</span> <span style="color: #000000;">      morethings;<br /> </span><span style="color: #008080;">12</span> <span style="color: #000000;">   }<br /> </span><span style="color: #008080;">13</span> <span style="color: #000000;">   </span><span style="color: #008000;">#</span><span style="color: #008000;"> last comes here</span></div> 5.The next Statement<br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;"> 1</span> <span style="color: #000000;">  </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (something) {<br /> </span><span style="color: #008080;"> 2</span> <span style="color: #000000;">   firstpart;<br /> </span><span style="color: #008080;"> 3</span> <span style="color: #000000;">   firstpart;<br /> </span><span style="color: #008080;"> 4</span> <span style="color: #000000;">   firstpart;<br /> </span><span style="color: #008080;"> 5</span> <span style="color: #000000;">   </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (somecondition) {<br /> </span><span style="color: #008080;"> 6</span> <span style="color: #000000;">     somepart;<br /> </span><span style="color: #008080;"> 7</span> <span style="color: #000000;">     somepart;<br /> </span><span style="color: #008080;"> 8</span> <span style="color: #000000;">     </span><span style="color: #0000ff;">next</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;"> 9</span> <span style="color: #000000;">   }<br /> </span><span style="color: #008080;">10</span> <span style="color: #000000;">   otherpart;<br /> </span><span style="color: #008080;">11</span> <span style="color: #000000;">   otherpart;<br /> </span><span style="color: #008080;">12</span> <span style="color: #000000;">   </span><span style="color: #008000;">#</span><span style="color: #008000;"> next comes here</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">13</span> <span style="color: #000000;">  }</span></div> <br /> <br /> 6.The redo Statement<br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;"> 1</span> <span style="color: #0000ff;">while</span><span style="color: #000000;"> (somecondition) {<br /> </span><span style="color: #008080;"> 2</span> <span style="color: #000000;">     </span><span style="color: #008000;">#</span><span style="color: #008000;"> redo comes here</span><span style="color: #008000;"><br /> </span><span style="color: #008080;"> 3</span> <span style="color: #000000;">    something;<br /> </span><span style="color: #008080;"> 4</span> <span style="color: #000000;">    something;<br /> </span><span style="color: #008080;"> 5</span> <span style="color: #000000;">    something;<br /> </span><span style="color: #008080;"> 6</span> <span style="color: #000000;">    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (somecondition) {<br /> </span><span style="color: #008080;"> 7</span> <span style="color: #000000;">         somestuff;<br /> </span><span style="color: #008080;"> 8</span> <span style="color: #000000;">         somestuff;<br /> </span><span style="color: #008080;"> 9</span> <span style="color: #000000;">        </span><span style="color: #0000ff;">redo</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">10</span> <span style="color: #000000;">}<br /> </span><span style="color: #008080;">11</span> <span style="color: #000000;">morething;<br /> </span><span style="color: #008080;">12</span> <span style="color: #000000;">morething;<br /> </span><span style="color: #008080;">13</span> <span style="color: #000000;">morething;<br /> </span><span style="color: #008080;">14</span> <span style="color: #000000;">}</span></div> <br /> 7.Expression Modifiers<br />   <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #000000;">exp2 </span><span style="color: #0000ff;">unless</span><span style="color: #000000;"> exp1; </span><span style="color: #008000;">#</span><span style="color: #008000;"> like: unless (exp1) { exp2; }</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;">exp2 </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> exp1; </span><span style="color: #008000;">#</span><span style="color: #008000;"> like: while (exp1) { exp2; }</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">3</span> <span style="color: #000000;">exp2 </span><span style="color: #0000ff;">until</span><span style="color: #000000;"> exp1; </span><span style="color: #008000;">#</span><span style="color: #008000;"> like: until (exp1) { exp2; }</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">4</span> <span style="color: #000000;">some_expression </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> control_expression; </span><span style="color: #008000;">#</span><span style="color: #008000;"> like if (control_expression) {  </span><span style="color: #000000;">some_expression;</span><span style="color: #000000;">}</span></div> <br /> 8.&& and || as Control Structures<br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #0000ff;">if</span><span style="color: #000000;"> (this) { that; } </span><span style="color: #008000;">#</span><span style="color: #008000;"> one way</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;">that </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> this; </span><span style="color: #008000;">#</span><span style="color: #008000;"> another way<br /> </span><span style="color: #008080;">3</span> <span style="color: #008000;"><br /> </span><span style="color: #008080;">4</span> <span style="color: #008000;">#Here's a third (and believe it or not, there are still others):</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">5</span> <span style="color: #000000;">this </span><span style="color: #000000;">&&</span><span style="color: #000000;"> that;<br /> </span>6 #Likewise, the logical-or works like the unless statement (or unless modifier). So you can replace:<br /> 7 unless (this) { that; }<br /> 8 #with:<br /> 9 this || that;<br /> </div> <br /> 9.Opening and Closing a Filehandle<br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #0000ff;">open</span><span style="color: #000000;">(FILEHANDLE</span><span style="color: #000000;">,</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">somename</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">); </span><span style="color: #008000;">#</span><span style="color: #008000;">opens the filehandle for reading</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;"><br /> </span><span style="color: #008080;">3</span> <span style="color: #0000ff;">open</span><span style="color: #000000;">(OUT</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">>outfile</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);  </span><span style="color: #008000;">#</span><span style="color: #008000;">open a file for writing</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">4</span> <span style="color: #000000;"><br /> </span><span style="color: #008080;">5</span> <span style="color: #0000ff;">open</span><span style="color: #000000;">(LOGFILE</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">>>mylogfile</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);  </span><span style="color: #008000;">#</span><span style="color: #008000;">you can open a file for appending<br /> 6 </span><span style="color: #2835ff;">close</span>(LOGFILE);</div> <br /> 10.A Slight Diversion: die<br />  <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #0000ff;">open</span><span style="color: #000000;">(DATAPLACE</span><span style="color: #000000;">,</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">>/tmp/dataplace</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">) </span><span style="color: #000000;">||</span><span style="color: #000000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #0000ff;">die</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">Sorry, I couldn't create /tmp/dataplace\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">3</span> <span style="color: #000000;"><br /> </span><span style="color: #008080;">4</span> <span style="color: #0000ff;">die</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">you gravy-sucking pigs</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">; </span><span style="color: #008000;">#</span><span style="color: #008000;">prints the file and line number</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">5</span> <span style="color: #000000;"><br /> </span><span style="color: #008080;">6</span> <span style="color: #0000ff;">die</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">you gravy-sucking pigs\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">; </span><span style="color: #008000;">#</span><span style="color: #008000;">print either</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">7</span> <span style="color: #000000;"><br /> </span><span style="color: #008080;">8</span> <span style="color: #0000ff;">open</span><span style="color: #000000;">(</span><span style="color: #0000ff;">LOG</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">>>logfile</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">) </span><span style="color: #000000;">||</span><span style="color: #000000;"> </span><span style="color: #0000ff;">die</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">cannot append: $!</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">; </span><span style="color: #008000;">#</span><span style="color: #008000;">  $!: </span><span style="color: #000000;">most recent operating </span><span style="color: #0000ff;">system</span><span style="color: #000000;"> error</span></div> <br /> 11.Using Filehandles<br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #0000ff;">open</span><span style="color: #000000;"> (EP</span><span style="color: #000000;">,</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">/etc/passwd</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);<br /> </span><span style="color: #008080;">2</span> <span style="color: #0000ff;">while</span><span style="color: #000000;"> (</span><span style="color: #000000;"><</span><span style="color: #000000;">EP</span><span style="color: #000000;">></span><span style="color: #000000;">) {<br /> </span><span style="color: #008080;">3</span> <span style="color: #000000;">        </span><span style="color: #0000ff;">chomp</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">4</span> <span style="color: #000000;">        </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">I saw $_ in the password file!\n</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">5</span> <span style="color: #000000;">}<br /> 6 close(EP);<br /> </span></div> <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #0000ff;">open</span><span style="color: #000000;">(OUT</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">>outfile</span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">);  </span><span style="color: #008000;">#</span><span style="color: #008000;">open a file for writing</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #0000ff;">print</span><span style="color: #000000;"> OUT </span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000; font-weight: bold;">What's going on in this file<img src="http://www.tkk7.com/Images/dot.gif" alt="" /></span><span style="color: #000000; font-weight: bold;">"</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">3</span> <span style="color: #0000ff;">close</span><span style="color: #000000;">(OUT);<br /> </span></div> <img src ="http://www.tkk7.com/persister/aggbug/294737.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/persister/" target="_blank">persister</a> 2009-09-11 15:23 <a href="http://www.tkk7.com/persister/archive/2009/09/11/294737.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>perl瀛︿範(fàn)絎旇涓?/title><link>http://www.tkk7.com/persister/archive/2009/03/18/260591.html</link><dc:creator>persister</dc:creator><author>persister</author><pubDate>Wed, 18 Mar 2009 14:00:00 GMT</pubDate><guid>http://www.tkk7.com/persister/archive/2009/03/18/260591.html</guid><wfw:comment>http://www.tkk7.com/persister/comments/260591.html</wfw:comment><comments>http://www.tkk7.com/persister/archive/2009/03/18/260591.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/persister/comments/commentRss/260591.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/persister/services/trackbacks/260591.html</trackback:ping><description><![CDATA[<p>1銆丄nchoring Patterns<br />     \b鎰忓懗鐫瀛楃杈圭晫銆備唬鐮侊細(xì)<br />     print "what's your name?";<br />     $name=<STDIN>;<br />     chomp($name);<br />     if($name=~ /^randl\b/i){<br />         print "matched\n";<br />     }else{<br />         print "not matched\n";<br />     }<br />     濡傛灉杈撳叆randl*,  *鏄瓧絎︺佹暟瀛楀拰涓嬪垝綰匡紝閭d箞閮戒細(xì)鎵撳嵃not matched<br />    鑰岃緭鍏?randl%"銆?randl fa"絳夊垯matched銆?br /> <br /> <br />     /fred\b/; # matches fred, but not frederick<br />     /\bmo/; # matches moe and mole, but not Elmo<br />     /\bFred\b/; # matches Fred but not Frederick or alFred<br />     /\b\+\b/; # matches "x+y" but not "++" or " + "<br />     /abc\bdef/; # never matches (impossible for a boundary there)<br />    word boundary鎸夊瓧闈㈡潵鐪嬫槸涓縐嶈竟鐣岋紝涓涓綅緗傚湪榪欎釜浣嶇疆涓よ竟鐨勫瓧絎︿竴涓笌\w鍖歸厤錛屼竴涓笌<br />    \W鍖歸厤錛岃繖鏄竴縐嶆儏鍐碉紱榪樻湁涓縐嶆儏鍐靛氨鏄紝涓涓瓧絎︿笌\w鍖歸厤錛岃屽彟涓涓瓧絎﹀槢錛岃涔堟槸<br />    瀛楃涓茬殑鎵撳ご錛岃涔堟槸緇撳熬銆傝孿b榪欎釜anchor鎭版伆闇瑕佸湪瀹冨嚭鐜扮殑浣嶇疆鏄竴涓獁ord boundary銆?br />    鍐嶇湅鏉?abc\bdef/錛孿b涓よ竟涓涓槸c錛屼竴涓槸d錛岄兘涓嶾w鍖歸厤錛岃繖宸蹭笉婊¤凍涓婅堪鐨勭涓縐嶆儏鍐碉紝<br />    鑷充簬絎簩縐嶆儏鍐碉紝鏇村姞涓嶄細(xì)鏄瓧絎︿覆鐨勬墦澶存垨鏈熬浜?jiǎn)銆傛墍浠b鍑虹幇鐨勫湴鏂逛笉鍙兘鏄痺ord boundary銆?/p> <p><br /> </p> <p>闄凩earning Perl涓殑鐗囨璇存槑錛?br /> </p> <p>if ($name =~ /^Randal/) {<br /> ## yes, it matches<br /> } else {<br /> ## no, it doesn't<br /> }<br /> Note that the regular expression is delimited by slashes. Within the slashes, spaces and other whitespace<br /> are significant, just as they are within strings.<br /> This almost does it, but it doesn't handle selecting randal or rejecting Randall. To accept randal,<br /> we add the ignore-case option, a small i appended after the closing slash. To reject Randall, we add a<br /> word boundary special marker (similar to vi and some versions of grep) in the form of "b in the regular<br /> expression. This ensures that the character following the first l in the regular expression is not another<br /> letter. This changes the regular expression to be /^randal"b/i, which means "randal at the<br /> beginning of the string, no letter or digit following, and OK to be in either case."<br /> <br /> </p> <img src ="http://www.tkk7.com/persister/aggbug/260591.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/persister/" target="_blank">persister</a> 2009-03-18 22:00 <a href="http://www.tkk7.com/persister/archive/2009/03/18/260591.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>perl榪炴帴mysql鏁版嵁搴?/title><link>http://www.tkk7.com/persister/archive/2009/03/16/260100.html</link><dc:creator>persister</dc:creator><author>persister</author><pubDate>Mon, 16 Mar 2009 13:46:00 GMT</pubDate><guid>http://www.tkk7.com/persister/archive/2009/03/16/260100.html</guid><wfw:comment>http://www.tkk7.com/persister/comments/260100.html</wfw:comment><comments>http://www.tkk7.com/persister/archive/2009/03/16/260100.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/persister/comments/commentRss/260100.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/persister/services/trackbacks/260100.html</trackback:ping><description><![CDATA[1銆佹煡鐪嬬郴緇熶笂鏄惁宸茬粡瀹夎濂戒簡(jiǎn)DBI錛宲erl -e "use DBI"錛屽鏋滄病鏈夊嚭鐜伴敊璇笖娌℃湁閫鍑猴紝琛ㄦ槑宸茬粡瀹夎<br />     姝ゆā鍧椼?br /> 2銆佸鏋滄湭瀹夎錛屽埌<a >www.cpan.org</a>榪涜涓嬭澆涓や釜妯″潡錛孌BI-1.607.tar.gz鍜孌BD-mysql-4.010榪涜瀹夎銆?br />     tar -xzvf DBI-1.607.tar.gz<br />     cd DBI-1.607<br />     perl Makefile.PL<br />     make<br />     make test<br />     make install<br />     DBD-myql-4.010涔熷悓鏍風(fēng)殑鏂瑰紡榪涜瀹夎銆?br /> 3銆侀氳繃涓嬮潰鐨刾erl鑴氭湰榪炴帴鏁版嵁搴擄細(xì)<br />     my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost","root","123456");<br />     my $sth = $dbh->("select * from clients");<br />     $sth->execute();<br />     while(my $ref = $sth->fetchrow_hashref())<br />     {<br />         print "cid=$ref->{'cid'} and cname=$ref->{'cname'}\n";<br />     }<br />     $sth->finish();<br />     $dbh->disconnect(); <img src ="http://www.tkk7.com/persister/aggbug/260100.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/persister/" target="_blank">persister</a> 2009-03-16 21:46 <a href="http://www.tkk7.com/persister/archive/2009/03/16/260100.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>apache鐨勫畨瑁呭拰perl嫻嬭瘯http://www.tkk7.com/persister/archive/2009/03/16/259958.htmlpersisterpersisterMon, 16 Mar 2009 02:54:00 GMThttp://www.tkk7.com/persister/archive/2009/03/16/259958.htmlhttp://www.tkk7.com/persister/comments/259958.htmlhttp://www.tkk7.com/persister/archive/2009/03/16/259958.html#Feedback0http://www.tkk7.com/persister/comments/commentRss/259958.htmlhttp://www.tkk7.com/persister/services/trackbacks/259958.html 2. 涓嬭澆鍚庣殑鏂囦歡褰㈠紡鏄痟ttpd-2.2.11.tar.gz.
    1)鍒╃敤鍛戒護(hù)tar xvfz *.tar.gz灝哸pache瑙e帇.
    2)cd httpd-2.2.11    3)鍒╃敤./configure --help鏌ョ湅甯姪淇℃伅,鐪嬬湅闇瑕侀厤緗摢浜涢夐」.鐢變簬鎴戣瑁卪ysql鍜宲hp,鎵浠ラ夋嫨浜?jiǎn)浠ヤ?br />         鍑犱釜閫夐」:./configure --prefix=/usr/local/apache2 --enable-rewrite   --with-mpm=worker  --enable-so
        鏈鍚庝竴涓緢閲嶈,濡傛灉瑕佽php,涓瀹氳鍐?鍓嶉潰涓や釜涓嶆槸蹇呴渶鐨?<濡傛灉涓嶆槑鐧介夐」鐨勫惈涔?鍘籫oogle.>
    4)make
    5)make install
3. 鍚姩Apache錛?br />     #cd /usr/local/apache2/bin
    #./apachectl start

   鍋滄帀apache鏄?br />     #cd /usr/local/apache2/bin
    #./apachectl stop
4.嫻嬭瘯瀹夎鏄惁鎴愬姛錛屾祻瑙堝櫒杈撳叆http://localhost, 欏甸潰鏄劇ずit works錛岃〃鏄巃pache瀹夎鎴愬姛.
5.嫻嬭瘯perl.鏂囦歡涓篶gitest.pl,鏀懼湪/usr/local/apache2/cgi-bin鐩綍涓紝騫朵笖chmod a+x cgitest.pl浣垮叾鍙墽琛?br /> 錛?/p>     #!/usr/bin/perl -w

    use CGI;
    {
        my $q = new CGI;
        print $q->header(),
        $q->start_html("hello,perl"),
        $q->h1('hello perl'),
        $q->end_html();
    }
6.鍦ㄦ祻瑙堝櫒涓緭鍏ワ細(xì)http://localhost/cgi-bin/cgitest.pl 鍗沖彲鐪嬪埌hello perl銆?br />
7.鑷畾涔夋枃浠跺瓨鏀句綅緗細(xì)
    # ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
    # ScriptAlias /cgi/ "/usr/local/www/"
      ScriptAlias / "/usr/local/www/"
 
  #<Directory "/usr/local/apache2/cgi-bin">
  <Directory "/usr/local/www">
榪欐牱灝卞彲浠ュ皢緗戦〉鏂囦歡瀛樻斁鍦?usr/local/www鐩綍
璁塊棶鐨勬椂鍊欙細(xì)http://localhost/cgitest.pl 鍗沖彲銆?nbsp;

persister 2009-03-16 10:54 鍙戣〃璇勮
]]>
Perl瀛︿範(fàn)絎旇浜?/title><link>http://www.tkk7.com/persister/archive/2009/03/14/259774.html</link><dc:creator>persister</dc:creator><author>persister</author><pubDate>Sat, 14 Mar 2009 15:33:00 GMT</pubDate><guid>http://www.tkk7.com/persister/archive/2009/03/14/259774.html</guid><wfw:comment>http://www.tkk7.com/persister/comments/259774.html</wfw:comment><comments>http://www.tkk7.com/persister/archive/2009/03/14/259774.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/persister/comments/commentRss/259774.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/persister/services/trackbacks/259774.html</trackback:ping><description><![CDATA[<p>1.the string abc as a regular expression by enclosing the string in slashes:<br />     while (<>) {<br />         if (/abc/) {<br />             print $_;<br />         }<br />     }<br /> 2.dot "." pattern<br />    This matches any single character except newline (\n).  For example, the pattern /a./ matches any two-letter sequence <br />    that starts with a and is not "a\n".<br /> 3.A pattern-matching character class <br />      open and close square brackets and a list of characters between the brackets. One and only one of these characters <br />      must be present at the corresponding part of the string for the pattern to match. For example,<br />      /[abcde]/<br />     [0123456789] # match any single digit<br />     [0-9] # same thing<br />     [0-9\-] # match 0-9, or minus<br />     [a-z0-9] # match any single lowercase letter or digit<br />     [a-zA-Z0-9_] # match any single letter, digit, or underscore<br />     There's also a negated character class, which is the same as a character class, but has a leading up-arrow<br />     (or caret: ^) immediately after the left bracket. 錛坕f caret ^ is not right after the left bracket,then it means starting with錛塗his character class matches any single character that is<br />     not in the list. For example:<br />     [^0-9] # match any single non-digit<br />     [^aeiouAEIOU] # match any single non-vowel<br />     [^\^] # match single character except an up-arrow<br /> <br />     Predefined Character Class Abbreviations<br />     Construct             Equivalent Class     Negated Construct     Equivalent Negated Class<br />     \d (a digit)             [0-9]                     \D (digits, not!)           [^0-9]<br />     \w (word char)     [a-zA-Z0-9_]         \W (words, not!)        [^a-zA-Z0-9_]<br />     \s (space char)     [ \r\t\n\f]                  \S (space, not!)           [^ \r\t\n\f] <br /> 4. Multipliers<br />     asterisk (*) as a grouping pattern. The asterisk indicates zero or more of the<br />         immediately previous character (or character class).<br />     Two other grouping patterns that work like this are the plus sign (+), meaning one or more of the<br />     immediately previous character, and the question mark (?), meaning zero or one of the immediately<br />     previous character. For example, the regular expression /fo+ba?r/ matches an f followed by one or<br />     more o's followed by a b, followed by an optional a, followed by an r.<br /> <br />     the general multiplier. The general multiplier consists of a pair of matching curly braces with one or two numbers<br />         inside, as in /x{5,10}/<br /> <br />     We could dispense with *, +, and ? entirely, since they are completely equivalent to {0,}, {1,}, and<br />     {0,1}. But it's easier to type the equivalent single punctuation character, and more familiar as well.<br /> <br />     If two multipliers occur in a single expression, the greedy rule is augmented with "leftmost is greediest."<br />     For example:<br />     $_ = "a xxx c xxxxxxxx c xxx d";<br />     /a.*c.*d/;<br />     In this case, the first ".*" in the regular expression matches all characters up to the second c, even<br />     though matching only the characters up to the first c would still allow the entire regular expression to<br />     match. Right now, this doesn't make any difference (the pattern would match either way), but later when<br />     we can look at parts of the regular expression that matched, it'll matter quite a bit.<br />     We can force any multiplier to be nongreedy (or lazy) by following it with a question mark:<br />     $_ = "a xxx c xxxxxxxx c xxx d";<br />     /a.*?c.*d/;<br />     Here, the a.*?c now matches the fewest characters between the a and c, not the most characters. This<br />     means the leftmost c is matched, not the rightmost. You can put such a question-mark modifier after any<br />     of the multipliers (?,+,*, and {m,n}).<br />     What if the string and regular expression were slightly altered, say, to:<br />     $_ = "a xxx ce xxxxxxxx ci xxx d";<br />     /a.*ce.*d/;<br />     In this case, if the .* matches the most characters possible before the next c, the next regular expression<br />     character (e) doesn't match the next character of the string (i). In this case, we get automatic<br />     backtracking: the multiplier is unwound and retried, stopping at someplace earlier (in this case, at the<br />     earlier c, next to the e).[2] A complex regular expression may involve many such levels of backtracking,<br />     leading to long execution times. In this case, making that match lazy (with a trailing "?") will actually<br />     simplify the work that Perl has to perform, so you may want to consider that.<br />     [2] Well, technically there was a lot of backtracking of the * operator to find the c's in the<br />     first place. But that's a little trickier to describe, and it works on the same principle. <br /> 5.Parentheses as memory</p> <p>    To recall a memorized part of a string, you must include a backslash followed by an integer. This pattern<br />     construct represents the same sequence of characters matched earlier in the same-numbered pair of<br />     parentheses (counting from one). For example,<br />         /fred(.)barney\1/;<br />     matches a string consisting of fred, followed by any single non-newline character, followed by<br />     barney, followed by that same single character. So, it matches fredxbarneyx, but not<br />     fredxbarneyy. Compare that with<br />         /fred.barney./;</p>     /a(.)b(.)c\2d\1/;   # it matches axbycydx, for example<br />     /a(.*)b\1c/; matches an a, followed by any number of characters (even zero) followed by b, followed by that same<br />     sequence of characters followed by c. So, it would match aFREDbFREDc, or even abc, but not aXXbXXXc. <img src ="http://www.tkk7.com/persister/aggbug/259774.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/persister/" target="_blank">persister</a> 2009-03-14 23:33 <a href="http://www.tkk7.com/persister/archive/2009/03/14/259774.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Perl瀛︿範(fàn)絎旇涓http://www.tkk7.com/persister/archive/2009/01/06/250113.htmlpersisterpersisterTue, 06 Jan 2009 07:42:00 GMThttp://www.tkk7.com/persister/archive/2009/01/06/250113.htmlhttp://www.tkk7.com/persister/comments/250113.htmlhttp://www.tkk7.com/persister/archive/2009/01/06/250113.html#Feedback0http://www.tkk7.com/persister/comments/commentRss/250113.htmlhttp://www.tkk7.com/persister/services/trackbacks/250113.html   
1 #!/usr/bin/perl
2    print ("Hello, world!\n");
   鍗蟲(chóng)墦鍗癏ello World錛?br /> 2銆佸彉閲忓畾涔夛細(xì)
 
1 #!/usr/bin/perl -w
2    print "What is your name? ";
3    $name = <STDIN>;  #瀹氫箟涓涓彉閲忛噰鐢ㄧ鍙?
4    chomp ($name);  #鍒犻櫎鏈瓧絎︿覆鏈鍚庣殑"\n"錛屽嵆鍥炶濺絎?/span>
5    print "Hello, $name!\n";
3銆佸湪perl涓紝鍙尯鍒嗗瓧絎︿覆鍜屾暟瀛楄繖涓ょ鏁版嵁綾誨瀷錛岃屼笖涓よ呬箣闂磋繕鍙互浜掓崲銆傚瓧絎︿覆鍒嗗崟寮曞彿瀛楃涓插拰
   鍙屽紩鍙峰瓧絎︿覆錛屾暟瀛楀垎鏁村瀷鍜屾誕鐐瑰瀷銆?br /> 4銆乻tring repetition operator錛?br />    "fred" x 3 # is "fredfredfred"
5銆?." operator
   "hello" . "world" # same as "helloworld"
6銆乧hop and chomp Functions
 
1 $x = "hello world";
2    chop($x); # $x is now "hello worl"
3 
4    $a = "hello world\n";
5    chomp ($a); # $a is now "hello world"
6    chomp ($a); # aha! no change in $a
7銆乿ariable interpolation錛?br />  
1 $a = "fred";
2    $b = "some text $a"# $b is now "some text fred"
3 
4    $fred = 'hi';
5    $barney = "a test of " . '$fred'# literally: 'a test of $fred'
6    $barney2= "a test of \$fred"# same thing
8銆乴ist literal
   1,2,3) # array of three values 1, 2, and 3
   ("fred",4.5) # two values, "fred" and 4.5
9銆乴ist constructor operator
   (1 .. 5) # same as (1, 2, 3, 4, 5)
   (1.2 .. 5.2) # same as (1.2, 2.2, 3.2, 4.2, 5.2)
   (1.3 .. 6.1) # same as (1.3,2.3,3.3,4.3,5.3)
10銆?quote word" function
   @a = ("fred","barney","betty","wilma"); # ugh!
   @a = qw(fred barney betty wilma); # better!
11銆丄rray Element Access
   @fred = (7,8,9);
   $b = $fred[0]; # give 7 to $b (first element of @fred)
   $fred[0] = 5; # now @fred = (5,8,9)
   @fred[0,1]; # same as ($fred[0],$fred[1])
12銆乸ush and pop Functions
   @mylist = (1,2,3);
   push(@mylist,4,5,6); # @mylist = (1,2,3,4,5,6)
   pop(@mylist); # @mylist = (1,2,3,4,5);
13銆乻hift and unshift Functions
   @fred = (5,6,7);
   unshift(@fred,2,3,4); # @fred is now (2,3,4,5,6,7)
   $x = shift(@fred); # $x gets 2, @fred is now (3,4,5,6,7)
14銆乺everse Function
   @a = (7,8,9);
   @b = reverse(@a); # gives @b the value of (9,8,7)
   @b = reverse(7,8,9); # same thing

14.1 <STDIN> as an Array:
@a = <STDIN>; # read standard input in a list context

15銆乀he if/unless Statement錛寀nless鍏跺疄灝辨槸if not
  
1 print "how old are you? ";
2    $a = <STDIN>;
3    chomp($a);
4    unless ($a < 18) {
5      print "Old enough! Cool! So go vote!\n";
6      $voter++;
7    }
16銆乼rue or false錛?br />    In Perl, the rules are slightly weird, but they give you the expected
   results. The control expression is evaluated for a string value in scalar
   context (if it's already a string, no change, but if it's a number, it is converted
   to a string).If this string is either the empty string (with a length of zero), or a
   string consisting of the single character "0" (the digit zero), then the value of
   the expression is false. Anything else is true automatically.Some examples below錛?br />
   0        # converts to "0", so false
   1-1      # computes to 0, then converts to "0", so false
   1        # converts to "1", so true
   ""       # empty string, so false
   "1"      # not "" or "0", so true
   "00"     # not "" or "0", so true (this is weird, watch out)
   "0.000"  # also true for the same reason and warning
   undef    # evaluates to "", so false
17銆乪lsif錛坣ot elseif or elif錛?br />   
1 if (some_expression_one) {
2        one_true_statement_1;
3    } elsif (some_expression_two) {
4       two_true_statement_1;
5    } else {
6       all_false_statement_1;
7    }
18銆亀hile/until Statement
  
1 $stops = 0;
2    do {
3       $stops++;
4       print "Next stop? ";
5       chomp($location = <STDIN>);
6    } until $stops > 5 || $location eq 'home';
19銆乫or Statement
   for ( initial_exp; test_exp; re-init_exp ) {
      statement_1;
   }
20銆乫oreach Statement
   @a = (1,2,3,4,5);
   foreach $b (reverse @a) {
     print $b;
   }
   or
   foreach (reverse @a) {
      print;  # $_ variable is used as a default for many of Perl's operations
   }
21銆丠ash
   %smooth = ("aaa","bbb","234.5",456.7);
22銆乲eys Function
   $fred{"aaa"} = "bbb";
   $fred{234.5} = 456.7;
   @list = keys(%fred); # @list gets ("aaa",234.5) or (234.5,"aaa")
23銆乿alues function
   %lastname = (); # force %lastname empty
   $lastname{"fred"} = "flintstone";
   $lastname{"barney"} = "rubble";
   @lastnames = values(%lastname); # grab the values
24銆乪ach Function
   while (($first,$last) = each(%lastname)) {
     print "The last name of $first is $last\n";
   }
25銆乨elete Function
   %fred = ("aaa","bbb",234.5,34.56); # give %fred two elements
   delete $fred{"aaa"};  //# %fred is now just one key-value pair
26銆丠ash Slices
   @score{"fred","barney","dino"} = (205,195,30);
   Hash slices can also be used to merge a smaller hash into a larger one. In this example,
   the smaller hash takes precedence in the sense that if there are duplicate keys,
   the value    from the smaller hash is used:
       %league{keys %score} = values %score;
    Here, the values of %score are merged into the %league hash. This is equivalent to
    the much slower operation:
            %league = (%league, %score); # merge %score into %league

27銆両nput from STDIN
   $a = <STDIN>; # read the next line
   @a = <STDIN>;
  
   Typically, one thing you want to do is read all lines one at a time and do something
   with each line. One common way to do this is:
      while (defined($line = <STDIN>)) {
               # process $line here
      }
28銆丏iamond Operator
   If you don't specify any filenames on the command line, the diamond operator reads
   from standard input automatically.
   #!/usr/bin/perl
   while (<>) {
        print $_;
   }

   or
   @ARGV = ("aaa","bbb","ccc");
   while (<>) { # process files aaa, bbb, and ccc
          print "this line is: $_";  //print every line in these files aaa,bbb and ccc
   }
29銆乸rintf for Formatted Output
   printf "%15s %5d %10.2f\n", $s, $n, $r;

30銆乮f (($words{$somename} || "groucho") eq $someguess) {
       return 1; # return value is true
    娉ㄦ剰涓婇潰鐨剕|涓嶆槸鎴栬繍綆楃錛岃屾槸璇村鏋滃乏杈圭殑鍊間負(fù)絀虹殑璇濓紝閭d箞灝辨槸鐢ㄥ彸杈圭殑鍊箋?br />


persister 2009-01-06 15:42 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 亚洲最大视频网站| 亚洲国产精品综合久久久| 亚洲一区二区久久| 久久精品国产亚洲av品善| 一级毛片免费在线观看网站| 97无码人妻福利免费公开在线视频| 91麻豆国产免费观看| 免费专区丝袜脚调教视频| 成人永久免费高清| 国产午夜亚洲精品午夜鲁丝片| 亚洲国产精品国自产拍电影| 亚洲一区精彩视频| 成人免费夜片在线观看| 暖暖免费日本在线中文| 成人网站免费观看| 亚洲第一区精品日韩在线播放| 九月丁香婷婷亚洲综合色| 亚洲二区在线视频| 老司机福利在线免费观看| 日本亚洲欧洲免费天堂午夜看片女人员| 99久久国产热无码精品免费| 亚洲国产黄在线观看| 亚洲宅男永久在线| 亚洲AV噜噜一区二区三区| 99久久免费国产特黄| 久久久久久国产a免费观看黄色大片 | 亚洲精品欧洲精品| 看全免费的一级毛片| 无码精品一区二区三区免费视频| 成年女性特黄午夜视频免费看 | 免费一看一级毛片人| 亚洲精品福利视频| 亚洲国产精品无码久久久秋霞1| 丝瓜app免费下载网址进入ios| 日本在线高清免费爱做网站| 亚洲精品无码AV中文字幕电影网站| 亚洲综合激情视频| 九一在线完整视频免费观看| 91麻豆最新在线人成免费观看| 亚洲日本中文字幕天堂网|