| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> perl >> xi yin C he Java cheng xu yuan mu guang de Perl5.6

xi yin C he Java cheng xu yuan mu guang de Perl5.6

2008-05-19 06:25:57 编辑來源:互联网 评论
 
 
 
本文为【吸引C和Java程序员目光的Perl5.6】的拼音翻译版
  Perl jie shi qi
  chu xue zhe ma shang jiu hui fa xian Perl zhong si hu mei you ren he bian yi qi 。 shi shi shang ,Perl jiao ben da duo shi you Perl jie shi qi zhi jie yun xing de , li ru UNIX xi tong xia de "Perl"、DOS/Windows xia de "perl.exe" jiu shi Perl jie shi qi 。 er zai MacOS zhong ze bu xu yao zhe xie jie shi qi 。 nin ke yi shi shi kan ru he yun xing Perl jiao ben 。 shou xian zai nin de cao zuo xi tong shang qi dong xiang ying de Perl jie shi qi , huo shi zai MacOS xi tong zhong zhi jie yun xing 。 zai da duo shu xi tong zhong , wen jian yi biao zhi (UNIX xi tong zhong wei Control-D) yong lai biao shi yong hu shu ru jie shu 。 yin ci zai UNIX xi tong zhong , xia mian zhe ge jiao ben jiang neng de dao "5+6" de ji suan jie guo :
  cong zui jian dan de Perl cheng xu ru shou
  perl
  (Perl is waiting for user input here, because no script name is given)
  print 5+6
  You press Control-D here
  11
  ke yi kan dao Perl jie shi qi yun xing le zhe ge zhi you yi xing de jiao ben cheng xu , bing shu ru gai biao da shi de ji suan jie guo 11。
  Perl jie shi qi you xu duo xuan xiang 。 li ru ,-e xuan xiang biao shi jiang ming ling xing de shu ru zuo wei jiao ben wen jian lai zhi xing , yin ci shang mian de jiao ben li zi ye ke yi zhe yang shi xian : zai ming ling xing shu ru perl -e'print 5+6'( zhu yi , yao yong dan yin hao jiang ming ling kuo qi lai )。 er -i xuan xiang ze lei si yu tong guo yi ge guo lv qi , yuan xu zai wen jian zhong bu tong de wei zhi jin xing bian ji 。-n he -p xuan xiang neng rang cheng xu yuan da kai huo guan bi shu chu 。-w xuan xiang yu C/C++ zhong de "-Wall" bian yi xuan xiang lei si , dou neng gou dui cheng xu zhong qian zai wen ti gei chu jing gao xin xi , dan yu -Wall bu tong de shi ,-w gong neng zai cheng xu yun xing shi ye shi bei ji huo de 。
  su du he Benchmark
  ren men chang chang na Perl yu C/C++ bi jiao , bing bao yuan Perl yun xing su du bu gou kuai 。 mou xie shi hou zhe de que shi shi shi , dan shi bing fei yong yuan ru ci 。 wo jian yi nin zai ren wei C huo C++ geng kuai zhi qian , shi yong Benchmark mo kuai shi shi kan (perldoc Benchmark)。 ci wai ,Perl neng hen fang bian di yu C/C++ dai ma huo ku lian jie , qie mou xie Perl nei zhi han shu bing bu bi C dai ma man , ru pai xu huo da yin deng 。 zhe li zai ci ti xing nin zai jian xin C/C++ bi jiao kuai zhi qian , xian shi yong yi xia Benchmark mo kuai 。
  yao ji zhu , guo zao de you hua wang wang shi cuo wu de gen yuan 。 ru guo nin zai Perl zhong xie le yi ge yuan xing , bing yong qi ta yu yan lai chong xie shi mei you wen ti de 。 yuan xing yi wei zhe neng gou fang bian di kai fa 。
  yu Java xiang bi er yan ,Perl ye neng gou hen hao di gong zuo 。Perl bu xiang Java na yang shan chang yu xian cheng , dan ta de Tk GUI jie mian gong ju xiang que bi Java de Swing GUI ku yao hao 。 bing qie Java dai ma zong shi neng gou lian jie dao Perl cheng xu zhong , fan zhi yi ran 。 yin ci , you shi nin ke yi tong guo mou zhong cheng du shang de jie he , shi de cheng xu zai liang fang mian dou zuo de hen hao 。
  yi chang 、 bian yi he wen dang
  Perl tong guo CPAN zhong de mo kuai huo shi qi nei zhi han shu eval() lai pao chu yi chang 。 jiu hao xiang zai C++ huo Java zhong tong guo try/catch dai ma kuai lai chu li yi chang yi yang ,eval han shu neng chu li mou ge dai ma duan huo mou ge zi fu chuan cao zuo de yi chang 。
  shi shi shang ,Perl cheng xu zai yun xing zhi qian huan shi xu yao bian yi de , zhi shi he C/C++/Java de bian yi fang shi bu xiang tong 。 zai she ji he xiao guo shang , ta he Java de zi jie jie shi guo cheng hen xiang si 。 guan yu bian yi de geng xiang jin nei rong , ke yi shen yue "perldoc perlrun" he "perldoc perlcc" wen dang 。
  ke yong POD ge shi lai jiang wen dang qian ru Perl cheng xu 。 zhe zhong wen dang qian ru fang shi bi Javadoc ge shi ( jin shi he yu API wen dang ) yao tong yong , dan bi bu shang C/C++/Java de zhu shi 。
  ji shi he C、C++ huo Java bi jiao qi lai ,Perl cheng xu ye bu suan shi yi zhong jie gou xing qiang de yu yan 。 li ru ,BEGIN yu ju kuai hui bei shou xian zhi xing , dan ta ke yi zai cheng xu zhong duo ci shuo ming 。 ding yi 、 bian liang he han shu ti ke yi zai cheng xu de ren yi wei zhi chu xian ,Perl suo ti gong di qiang da gong neng ke yi zui hao di man zu zhe zhong sui yi xing 。
  you yu zhe zhong song san jie gou 、 qian ru de zhu shi 、 yi ji wei zhui qiu fang bian er dao zhi de ling ren hun xiao de yu ju , shi de shu xie Perl cheng xu geng xiang shi zai xie yi feng ying wen xin jian 。
  Perl de rong cuo neng li
  Perl bi C/C++/Java geng neng rong ren yi xie mo hu di xie fa 。 li ru ke yi yong dou hao lai fen ge yu ju huo han shu de shen shu :
  yu ju zhi jian huo han shu shen shu zhi jian de fen ge fu
  print 'Hello', ' ', 'there.', "\n";
  # print "Hello there\n"
  foreach (1..10)
  {
  my $i;
  $i = $_ * 2, print "$i\n";
  # print evens from 2 to 20
  }
  Perl neng jin zui da ke neng di xiao chu zhe xie yu ju ke neng yin qi de qi yi 。 dang ran , you xie shi hou reng you wu fa jie jue de qi yi ( zai zhe yi dian shang ,Perl jiu xiang ying yu yi yang )。
  Perl zhong ling yi ge rong yi yin qi qi yi de di fang zai yu : bian liang jing chang hui bei yin han shi yong 。 li ru ,"print" yu ju que sheng shi hui da yin $_ bian liang de zhi 。 zai qi ta yi xie han hun de yu ju cao zuo zhong ,$_ bian liang ye shi ta men de que sheng zhi , zhe jiu zao cheng le yi zhong hun luan 。 li ru :
  yin han shi yong bian liang
  $_ = "hello";
  s/hello/hi/;
  # $_ is "hi" now
  print;
  # prints "hi"
  zhe li ni ke yi kan dao , shi yong que sheng bian liang neng rang bian cheng fang bian jian jie 。 ye jiu shi shuo ,Perl he ying yu lei si , tong guo mou zhong mo hu xing lai jian hua biao da shi 。
  yi xiang ren wu duo zhong shi xian
  (There's more than one way to do it ,TMTOWTDI)
  suo you de yu yan zai jie jue wen ti shi dou you zi ji de fang fa 。 zai C li mian ,for() xun huan shi zai yi ding fan wei nei chong fu de zui hao fang fa ; zai Java li , jing tai han shu de tiao yong shi zhi jie tong guo lei er bu shi mou ge shi li 。
  dan dui yu tong yi jian shi qing ,Perl zhi shao you liang zhong jie jue fang fa 。TMTOWTDI yuan ze jiu shi Perl de zuo you ming , ge zhong chu li shang de cha yi zai Perl bian cheng zhong shi shen shou gu li de 。
  xia mian lai kan yi ge da yin shu zu yuan su de li zi 。 suo you de biao da fang fa dou da dao tong yi mu de 。
  da yin shu zu yuan su
  print foreach @array;
  foreach (@array) {print};
  map {print} @array;
  print @array;
  yao li jie yi shang zhe xie dai ma de wei yi tu jing jiu shi zhang wo suo you Perl de yu fa 。 bu yao dan xin na zhong fang fa cai shi zheng que de , yin wei shi xian tong yi mu biao zong shi you duo zhong zheng que de fang fa 。 kao lv zhe xie bu tong de biao da fang shi , nin ke yi geng shen ke ti hui Perl de zhe ge zuo you ming 。
  ling wai , sui ran yi ge ren wu de shi xian you duo zhong fang fa , dan zhe bing bu yi wei zhe suo you fang fa dou shi zheng que de 。 tong chang qing kuang xia , geng you ke neng xie chu de shi yi xie cuo wu dai ma 。 wei le bao zheng dai ma de zheng que xing , zui hao jin liang shi yong na xie Perl nei zhi de han shu , er jiao shao shi yong zi ji suo bian xie de han shu , bing qie zhu yi zheng ming bing ji lu zhe xie bu na me xian ran de fang fa 。
  zheng ze biao da shi
  ru guo mei you chu shi hua , zheng ze biao da shi hen you ke neng zao cheng yi pian hun luan 。 da duo shu ren dou xiang xin zheng ze biao da shi shi you Kalahari bushmen fa ming de , ta shen tou dao le da xue de ji suan ji ke xue bian cheng de suo you fang mian 。
  Perl de zheng ze biao da shi shi cong shell jiao ben cheng xu yi ji awk/grep gong ju zhong ji cheng er lai de 。 dan ta de neng li que yuan yuan chao chu le yuan lai de mo xing 。
  ji chu de zheng ze biao da shi shi fei chang rong yi shu xie de , dan nan yi du dong 。 li ru "con\w+" he "contra"、"contrary" pi pei , dan yu "pro" huo "con" dou bu pi pei 。 ran er zai Perl 5.6.0 zhong , zheng ze biao da shi bei gu hua le 。Unicode zi fu ji 、 mo shi nei ren yi dai ma cao zuo 、flag toggles、 tiao jian biao da shi yi ji qi ta te zheng dou bei tian jia dao zheng ze biao da shi ku zhong 。
  dui yu chu xue zhe de yi ge zui hao de jian yi jiu shi : shou xian xue xi zui ji ben de zheng ze biao da shi ( shen yue zi liao bu fen , huo "perldoc perlre" shen kao shou ce ), shao hou cai jin yi bu xue xi na xie fu duo de gao ji te xing 。 you yu zheng ze biao da shi bi xu quan xie zai yi qi , zhong jian mei you ban fa tian jia zhu shi , zhe jiu rang ta men cheng wei suo you Perl dai ma zhong zui nan du dong de yi bu fen 。 yin ci jian yi da jia shu xie yi cheng xing de dai ma 。
  zai C/C++/Java zhong zheng ze biao da shi shu yu wai bu de han shu bao , dan Perl shi mu qian zui jia de zheng ze biao da shi sou suo he dai huan gong ju 。 zai ji shao shu qing kuang xia , ta ke neng hui bi chun C cheng xu man yi xie , dan dui yu na xie chun cui mian xiang zheng ze biao da shi de wen ti ,Perl yi ran shi nin shou xuan de gong ju 。
  biao liang 、 shu zu he ha xi san lie
  he C、C++、Java zhong bian liang bu tong de shi ,Perl de bian liang de lei xing shi you qi ming zi jue ding de , bing qie hui zi dong chu shi hua cheng xiang ying lei xing 。 zhe yi dian rang Perl chu xue zhe jiao de hen bu xi guan , dan ta fei chang di zhi guan er yi yu li jie 。
  bi zhe tui jian shi yong "use strict"。 tong guo ta ke yi bao zheng bian liang zai shi yong zhi qian sheng ming , cong er bi mian da zi cuo wu deng yin qi de cheng xu cuo wu 。
  ru guo mei you zuo dao zhe yi dian , ze you ke neng yu dao xia mian zhe yang de wen ti :
  yi ge chang jian de da zi cuo wu
  $i = 5;
  print $j;
  # print $i
  ci li zi zhong , cheng xu yuan ben lai yao da yin bian liang i de zhi , jie guo que qiao cheng le j。Perl bing bu hui jiao de zhe duan dai ma you shen me wen ti , ta hui ji xu zhi xing da yin yu ju , xian shi $j de zhi ji shen me dou mei you 。 you xie shi hou ,Perl de zi dong sheng cheng dui xiang de que hen you yong , dan yi wo de jing yan lai shuo , zui hao huan shi yong "use strict" lai guan diao zhe yi zi dong gong neng , cong er bi mian shang shu wen ti 。
  Perl bian liang ke yi shi biao liang (scalars)、 shu zu (arrays) huo ha xi san lie (hashes, you jiao zuo guan lian shu zu )。( shi shi shang ,Perl zhong you duo zhong shu ju lei xing , dan shi cheng xu yuan bing bu hui zhi jie mian dui ta men 。) ci wai ye ke yi shi yin yong , tong chang ta men ye shi yi zhong biao liang lei xing 。 qi zhong biao liang ming cheng yi "$" kai tou , shu zu ming yi "@" kai tou , er san lie ze yi "%" kai tou 。
  biao liang shi Perl zhong zui jian dan de shu ju lei xing 。 mei ge biao liang dou you wei yi de zhi , huo zhe shi zi fu chuan huo zhe shi yin yong 。 zai bi yao de shi hou , zi fu chuan he shu zi ke yi hu xiang zhuan hua 。 zhe chang rang chu xue zhe jiao de xin xi yi chang 。 kan yi xia zhe ge li zi :
  biao liang
  $i = "hi there";
  print 1+$i;
  # prints 1
  qi zhong biao liang $i de zhi shi zi fu chuan "hi there", ta dui ying de shu zhi wei 0。 yin ci 1 + "hi there" de zhi wei 1, cheng xu yun xing jie guo wei 1。
  bu guo zhe bing bu yi wei zhe Perl jie shi qi zai dui mou ge biao liang fen bie kao lv qi zi fu chuan lei xing he shu zi lei xing 。 shi shi shang , zai nei cun zhong zhi shi yi ge han you mou ge zhi de biao liang 。 ru guo zai shu zhi yun suan de yu ju zhong ( ru jia fa ), zhe ge biao liang zhi jiu zhuan hua cheng shu zhi xing shi ; ru guo zai zi fu chuan cao zuo yu ju zhong ( li ru da yin ), ze yi zi fu chuan xing shi zhi xing 。 dan wu lun yi shen me xing shi yun suan , gai biao liang bian liang shi zhi shang zhi you yi ge zhi 。
  wei ding yi de biao liang de zhi wei "undef"。 ru guo zai C/C++/Java cheng xu zhong , nin ke yi jiang qi ta zhi yu null bi jiao , dan zai Perl zhong que bu neng na ren he dong xi lai yu "undef" zuo bi jiao 。 ke yong zhe yang
  【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
  Perl jie shi qi    chu xue zhe ma shang jiu hui fa xian Perl zhong si hu mei you ren he bian yi qi 。 shi shi shang ,Perl jiao ben da duo shi you Perl jie shi qi zhi jie yun xing de , li ru UNIX xi tong xia de "Perl"、DOS/Windows xia de "perl.exe" jiu shi Perl jie shi qi 。 er zai MacOS zhong ze bu xu yao zhe xie jie shi qi 。 nin ke yi shi shi kan ru he yun xing Perl jiao ben 。 shou xian zai nin de cao zuo xi tong shang qi dong xiang ying de Perl jie shi qi , huo shi zai MacOS xi tong zhong zhi jie yun xing 。 zai da duo shu xi tong zhong , wen jian yi biao zhi (UNIX xi tong zhong wei Control-D) yong lai biao shi yong hu shu ru jie shu 。 yin ci zai UNIX xi tong zhong , xia mian zhe ge jiao ben jiang neng de dao "5+6" de ji suan jie guo :    cong zui jian dan de Perl cheng xu ru shou    perl   (Perl is waiting for user input here, because no script name is given)   print 5+6   You press Control-D here   11    ke yi kan dao Perl jie shi qi yun xing le zhe ge zhi you yi xing de jiao ben cheng xu , bing shu ru gai biao da shi de ji suan jie guo 11。   Perl jie shi qi you xu duo xuan xiang 。 li ru ,-e xuan xiang biao shi jiang ming ling xing de shu ru zuo wei jiao ben wen jian lai zhi xing , yin ci shang mian de jiao ben li zi ye ke yi zhe yang shi xian : zai ming ling xing shu ru perl -e'print 5+6'( zhu yi , yao yong dan yin hao jiang ming ling kuo qi lai )。 er -i xuan xiang ze lei si yu tong guo yi ge guo lv qi , yuan xu zai wen jian zhong bu tong de wei zhi jin xing bian ji 。-n he -p xuan xiang neng rang cheng xu yuan da kai huo guan bi shu chu 。-w xuan xiang yu C/C++ zhong de "-Wall" bian yi xuan xiang lei si , dou neng gou dui cheng xu zhong qian zai wen ti gei chu jing gao xin xi , dan yu -Wall bu tong de shi ,-w gong neng zai cheng xu yun xing shi ye shi bei ji huo de 。    su du he Benchmark    ren men chang chang na Perl yu C/C++ bi jiao , bing bao yuan Perl yun xing su du bu gou kuai 。 mou xie shi hou zhe de que shi shi shi , dan shi bing fei yong yuan ru ci 。 wo jian yi nin zai ren wei C huo C++ geng kuai zhi qian , shi yong Benchmark mo kuai shi shi kan (perldoc Benchmark)。 ci wai ,Perl neng hen fang bian di yu C/C++ dai ma huo ku lian jie , qie mou xie Perl nei zhi han shu bing bu bi C dai ma man , ru pai xu huo da yin deng 。 zhe li zai ci ti xing nin zai jian xin C/C++ bi jiao kuai zhi qian , xian shi yong yi xia Benchmark mo kuai 。    yao ji zhu , guo zao de you hua wang wang shi cuo wu de gen yuan 。 ru guo nin zai Perl zhong xie le yi ge yuan xing , bing yong qi ta yu yan lai chong xie shi mei you wen ti de 。 yuan xing yi wei zhe neng gou fang bian di kai fa 。    yu Java xiang bi er yan ,Perl ye neng gou hen hao di gong zuo 。Perl bu xiang Java na yang shan chang yu xian cheng , dan ta de Tk GUI jie mian gong ju xiang que bi Java de Swing GUI ku yao hao 。 bing qie Java dai ma zong shi neng gou lian jie dao Perl cheng xu zhong , fan zhi yi ran 。 yin ci , you shi nin ke yi tong guo mou zhong cheng du shang de jie he , shi de cheng xu zai liang fang mian dou zuo de hen hao 。    yi chang 、 bian yi he wen dang   Perl tong guo CPAN zhong de mo kuai huo shi qi nei zhi han shu eval() lai pao chu yi chang 。 jiu hao xiang zai C++ huo Java zhong tong guo try/catch dai ma kuai lai chu li yi chang yi yang ,eval han shu neng chu li mou ge dai ma duan huo mou ge zi fu chuan cao zuo de yi chang 。    shi shi shang ,Perl cheng xu zai yun xing zhi qian huan shi xu yao bian yi de , zhi shi he C/C++/Java de bian yi fang shi bu xiang tong 。 zai she ji he xiao guo shang , ta he Java de zi jie jie shi guo cheng hen xiang si 。 guan yu bian yi de geng xiang jin nei rong , ke yi shen yue "perldoc perlrun" he "perldoc perlcc" wen dang 。    ke yong POD ge shi lai jiang wen dang qian ru Perl cheng xu 。 zhe zhong wen dang qian ru fang shi bi Javadoc ge shi ( jin shi he yu API wen dang ) yao tong yong , dan bi bu shang C/C++/Java de zhu shi 。    ji shi he C、C++ huo Java bi jiao qi lai ,Perl cheng xu ye bu suan shi yi zhong jie gou xing qiang de yu yan 。 li ru ,BEGIN yu ju kuai hui bei shou xian zhi xing , dan ta ke yi zai cheng xu zhong duo ci shuo ming 。 ding yi 、 bian liang he han shu ti ke yi zai cheng xu de ren yi wei zhi chu xian ,Perl suo ti gong di qiang da gong neng ke yi zui hao di man zu zhe zhong sui yi xing 。    you yu zhe zhong song san jie gou 、 qian ru de zhu shi 、 yi ji wei zhui qiu fang bian er dao zhi de ling ren hun xiao de yu ju , shi de shu xie Perl cheng xu geng xiang shi zai xie yi feng ying wen xin jian 。   Perl de rong cuo neng li   Perl bi C/C++/Java geng neng rong ren yi xie mo hu di xie fa 。 li ru ke yi yong dou hao lai fen ge yu ju huo han shu de shen shu :    yu ju zhi jian huo han shu shen shu zhi jian de fen ge fu   print 'Hello', ' ', 'there.', "\n";   # print "Hello there\n"   foreach (1..10)   {   my $i;   $i = $_ * 2, print "$i\n";   # print evens from 2 to 20   }   Perl neng jin zui da ke neng di xiao chu zhe xie yu ju ke neng yin qi de qi yi 。 dang ran , you xie shi hou reng you wu fa jie jue de qi yi ( zai zhe yi dian shang ,Perl jiu xiang ying yu yi yang )。   Perl zhong ling yi ge rong yi yin qi qi yi de di fang zai yu : bian liang jing chang hui bei yin han shi yong 。 li ru ,"print" yu ju que sheng shi hui da yin $_ bian liang de zhi 。 zai qi ta yi xie han hun de yu ju cao zuo zhong ,$_ bian liang ye shi ta men de que sheng zhi , zhe jiu zao cheng le yi zhong hun luan 。 li ru :    yin han shi yong bian liang   $_ = "hello";   s/hello/hi/;   # $_ is "hi" now   print;   # prints "hi"    zhe li ni ke yi kan dao , shi yong que sheng bian liang neng rang bian cheng fang bian jian jie 。 ye jiu shi shuo ,Perl he ying yu lei si , tong guo mou zhong mo hu xing lai jian hua biao da shi 。    yi xiang ren wu duo zhong shi xian   (There's more than one way to do it ,TMTOWTDI)    suo you de yu yan zai jie jue wen ti shi dou you zi ji de fang fa 。 zai C li mian ,for() xun huan shi zai yi ding fan wei nei chong fu de zui hao fang fa ; zai Java li , jing tai han shu de tiao yong shi zhi jie tong guo lei er bu shi mou ge shi li 。    dan dui yu tong yi jian shi qing ,Perl zhi shao you liang zhong jie jue fang fa 。TMTOWTDI yuan ze jiu shi Perl de zuo you ming , ge zhong chu li shang de cha yi zai Perl bian cheng zhong shi shen shou gu li de 。    xia mian lai kan yi ge da yin shu zu yuan su de li zi 。 suo you de biao da fang fa dou da dao tong yi mu de 。    da yin shu zu yuan su   print foreach @array;   foreach (@array) {print};   map {print} @array;   print @array;    yao li jie yi shang zhe xie dai ma de wei yi tu jing jiu shi zhang wo suo you Perl de yu fa 。 bu yao dan xin na zhong fang fa cai shi zheng que de , yin wei shi xian tong yi mu biao zong shi you duo zhong zheng que de fang fa 。 kao lv zhe xie bu tong de biao da fang shi , nin ke yi geng shen ke ti hui Perl de zhe ge zuo you ming 。    ling wai , sui ran yi ge ren wu de shi xian you duo zhong fang fa , dan zhe bing bu yi wei zhe suo you fang fa dou shi zheng que de 。 tong chang qing kuang xia , geng you ke neng xie chu de shi yi xie cuo wu dai ma 。 wei le bao zheng dai ma de zheng que xing , zui hao jin liang shi yong na xie Perl nei zhi de han shu , er jiao shao shi yong zi ji suo bian xie de han shu , bing qie zhu yi zheng ming bing ji lu zhe xie bu na me xian ran de fang fa 。    zheng ze biao da shi    ru guo mei you chu shi hua , zheng ze biao da shi hen you ke neng zao cheng yi pian hun luan 。 da duo shu ren dou xiang xin zheng ze biao da shi shi you Kalahari bushmen fa ming de , ta shen tou dao le da xue de ji suan ji ke xue bian cheng de suo you fang mian 。   Perl de zheng ze biao da shi shi cong shell jiao ben cheng xu yi ji awk/grep gong ju zhong ji cheng er lai de 。 dan ta de neng li que yuan yuan chao chu le yuan lai de mo xing 。    ji chu de zheng ze biao da shi shi fei chang rong yi shu xie de , dan nan yi du dong 。 li ru "con\w+" he "contra"、"contrary" pi pei , dan yu "pro" huo "con" dou bu pi pei 。 ran er zai Perl 5.6.0 zhong , zheng ze biao da shi bei gu hua le 。Unicode zi fu ji 、 mo shi nei ren yi dai ma cao zuo 、flag toggles、 tiao jian biao da shi yi ji qi ta te zheng dou bei tian jia dao zheng ze biao da shi ku zhong 。    dui yu chu xue zhe de yi ge zui hao de jian yi jiu shi : shou xian xue xi zui ji ben de zheng ze biao da shi ( shen yue zi liao bu fen , huo "perldoc perlre" shen kao shou ce ), shao hou cai jin yi bu xue xi na xie fu duo de gao ji te xing 。 you yu zheng ze biao da shi bi xu quan xie zai yi qi , zhong jian mei you ban fa tian jia zhu shi , zhe jiu rang ta men cheng wei suo you Perl dai ma zhong zui nan du dong de yi bu fen 。 yin ci jian yi da jia shu xie yi cheng xing de dai ma 。    zai C/C++/Java zhong zheng ze biao da shi shu yu wai bu de han shu bao , dan Perl shi mu qian zui jia de zheng ze biao da shi sou suo he dai huan gong ju 。 zai ji shao shu qing kuang xia , ta ke neng hui bi chun C cheng xu man yi xie , dan dui yu na xie chun cui mian xiang zheng ze biao da shi de wen ti ,Perl yi ran shi nin shou xuan de gong ju 。    biao liang 、 shu zu he ha xi san lie    he C、C++、Java zhong bian liang bu tong de shi ,Perl de bian liang de lei xing shi you qi ming zi jue ding de , bing qie hui zi dong chu shi hua cheng xiang ying lei xing 。 zhe yi dian rang Perl chu xue zhe jiao de hen bu xi guan , dan ta fei chang di zhi guan er yi yu li jie 。    bi zhe tui jian shi yong "use strict"。 tong guo ta ke yi bao zheng bian liang zai shi yong zhi qian sheng ming , cong er bi mian da zi cuo wu deng yin qi de cheng xu cuo wu 。    ru guo mei you zuo dao zhe yi dian , ze you ke neng yu dao xia mian zhe yang de wen ti :    yi ge chang jian de da zi cuo wu   $i = 5;   print $j;   # print $i    ci li zi zhong , cheng xu yuan ben lai yao da yin bian liang i de zhi , jie guo que qiao cheng le j。Perl bing bu hui jiao de zhe duan dai ma you shen me wen ti , ta hui ji xu zhi xing da yin yu ju , xian shi $j de zhi ji shen me dou mei you 。 you xie shi hou ,Perl de zi dong sheng cheng dui xiang de que hen you yong , dan yi wo de jing yan lai shuo , zui hao huan shi yong "use strict" lai guan diao zhe yi zi dong gong neng , cong er bi mian shang shu wen ti 。   Perl bian liang ke yi shi biao liang (scalars)、 shu zu (arrays) huo ha xi san lie (hashes, you jiao zuo guan lian shu zu )。( shi shi shang ,Perl zhong you duo zhong shu ju lei xing , dan shi cheng xu yuan bing bu hui zhi jie mian dui ta men 。) ci wai ye ke yi shi yin yong , tong chang ta men ye shi yi zhong biao liang lei xing 。 qi zhong biao liang ming cheng yi "$" kai tou , shu zu ming yi "@" kai tou , er san lie ze yi "%" kai tou 。    biao liang shi Perl zhong zui jian dan de shu ju lei xing 。 mei ge biao liang dou you wei yi de zhi , huo zhe shi zi fu chuan huo zhe shi yin yong 。 zai bi yao de shi hou , zi fu chuan he shu zi ke yi hu xiang zhuan hua 。 zhe chang rang chu xue zhe jiao de xin xi yi chang 。 kan yi xia zhe ge li zi :    biao liang   $i = "hi there";   print 1+$i;   # prints 1    qi zhong biao liang $i de zhi shi zi fu chuan "hi there", ta dui ying de shu zhi wei 0。 yin ci 1 + "hi there" de zhi wei 1, cheng xu yun xing jie guo wei 1。    bu guo zhe bing bu yi wei zhe Perl jie shi qi zai dui mou ge biao liang fen bie kao lv qi zi fu chuan lei xing he shu zi lei xing 。 shi shi shang , zai nei cun zhong zhi shi yi ge han you mou ge zhi de biao liang 。 ru guo zai shu zhi yun suan de yu ju zhong ( ru jia fa ), zhe ge biao liang zhi jiu zhuan hua cheng shu zhi xing shi ; ru guo zai zi fu chuan cao zuo yu ju zhong ( li ru da yin ), ze yi zi fu chuan xing shi zhi xing 。 dan wu lun yi shen me xing shi yun suan , gai biao liang bian liang shi zhi shang zhi you yi ge zhi 。    wei ding yi de biao liang de zhi wei "undef"。 ru guo zai C/C++/Java cheng xu zhong , nin ke yi jiang qi ta zhi yu null bi jiao , dan zai Perl zhong que bu neng na ren he dong xi lai yu "undef" zuo bi jiao 。 ke yong zhe yang   
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
可爱小魔女
夏日小桃红
琦吖囡半熟乖巧清新写真
天使的微笑
痞子的甘南日记
疑是银河落九天
雪域坝上四——纯美色
冬日恋歌——西城杨柳弄轻柔
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有