| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> perl >> shi yong Perl chu li dian zi you jian de fang fa de yan hua

shi yong Perl chu li dian zi you jian de fang fa de yan hua

2008-05-30 23:04:00 编辑來源:互联网 评论
 
 
 
本文为【使用Perl处理电子邮件的方法的演化】的拼音翻译版
  yi zhe / zuo zhe :chunzi
  chu chu : zhong guo Perl xie hui FPC(Foundation of Perlchina)
  yuan ming :The Evolution of Perl Email Handling
  zuo zhe :Simon Cozens
  yuan wen :http://www.perl.com/pub/a/2004/06/10/email.html
  fa biao :June 10, 2004
  qing bao hu zuo zhe de zhu zuo quan , wei hu zuo zhe lao dong de jie jing 。
  mei tian wo dou yao hua fei da liang de shi jian zai dian zi you jian xiang guan de gong zuo shang , huo zhe tong guo you jian lai he qi ta gong zuo huo ban lian xi , huo zhe rao you xing zhi di fen xi , suo yin , chong xin zu zhi yi ji wa jue you jian nei rong 。 hen zi ran de ,Perl xie zhu wo zuo zhe xie shi qing 。 zai CPAN shang you hen duo xian cheng de mo kuai ke yi yong lai chu li dian zi you jian , wo men jiang jie shao qi zhong ji ge zhu yao de 。 tong shi wo men ye jiang guan zhu you wo he Richard Clamp,Simon Wistow yi ji qi ta huo ban suo zhi li de Perl dian zi you jian xiang mu (Perl Email Project), gai xiang mu de mu biao shi ti gong yi xi lie jian dan de , you xiao de , jing zhun de you jian chu li mo kuai 。
  you jian xiao xi de chu li wo men cong yi xie bi jiao jian dan de , yong lai miao hui yi feng dan du you jian , ti gong dui you jian tou he you jian ti de fang wen , shen zhi xiu gai ta men de xin xi de na xie mo kuai kai shi jie shao 。 suo you de zhe xie mo kuai de zeng zu fu dou shi Mail::Internet , you Graham Barr chuang jian , mu qian Mark Overmeer zai wei hu 。 gai mo kuai ti gong le tong guo shu zu ( yuan su wei zi fu chuan xing ) huo zhe wen jian ju bing lai du qu xin jian nei rong de gou zao qi , bing tong guo ta fan hui yi ge miao shu gai xin jian de Mail::Internet dui xiang 。 zai xia mian de li zi zhong , wo men shi yong bian liang $rfc2822 lai biao shi zi fu chuan xing shi de you jian xin xi nei rong 。 my $obj = Mail::Internet-new( [ split /\n/, $rfc2822 ] );
  Mail::Internet cong xin jian zhong ti qu gou zao chu yi ge you jian tou dui xiang , bing lian dai you jian ti xin xi 。 you jian tou dui xiang de lei wei Mail::Header 。 ni ke yi tong guo gai dui xiang huo qu huo zhe she zhi you jian tou de xin xi : my $subject = $obj-head-get("Subject"); $obj-head-replace("Subject", "New subject");
  er du qu huo zhe bian ji you jian ti nei rong de cao zuo , ze ke yi shi yong body fang fa : my $old_body = $obj-body; $obj-body("Wasn't worth reading anyway.");
  dao xian zai wei zhi wo huan mei you ti dao guo ren he guan yu MIME de dong xi 。 dui yu jian dan de ren wu lai shuo ,Mail::Internet que shi fei chang fang bian , bu guo ta bing bu wan quan zhi chi dui MIME de chu li 。 xie tian xie di ,MIME::Entity zuo wei yi ge wei MIME er kao lv she ji de Mail::Internet zi lei , yuan xu ni du qu MIME xiao xi de mei yi ge du li de bu fen (part): my $num_parts = $obj-parts; for (0..$num_parts) { my $part = $obj-parts($_); ... }
  ru guo Mail::Internet he MIME::Entity dou bu shi he ni , ni ke yi shi shi Mark Overmeer zi ji de Mail::Message mo kuai , gai mo kuai shi ling ren yin xiang shen ke de Mail::Box mo kuai zhong de yi bu fen 。Mail::Message shi ge ji fu te se de 、 gong neng quan mian de mo kuai , dan zhe xie you dian bing bu zong yi wei zhe bao yang 。 Mail::Message dui xiang tong chang dou shi zai Mail::Box du qu yi ge dian zi you jian wen jian jia de shi hou , zai nei bu gou jian de 。 dang ran ta ye ke yi tong guo read fang fa lai du qu yi feng xin jian : $obj = Mail::Message-read($rfc2822);
  jiu xiang Mail::Internet yi yang , you jian xiao xi bei fen ge wei you jian tou he you jian ti , er yu Mail::Internet bu tong de shi , you jian ti ye shi yi ge dui xiang 。 wo men ru ci du qu you jian tou : $obj-head-get("Subject");
  huo zhe , ru guo shi Subject tou xin xi yi ji qi ta chang jian de you jian tou xin xi , ke yi ru ci du qu : $obj-subject;
  wo zhao bu dao zhi jie she zhi tou xin xi de fang fa , suo yi zui zhong ke neng xu yao zhe yang zuo : $obj-head-delete($header); $obj-head-add($header, $_) for @data;
  du qu you jian ti nei rong zuo wei zi fu chuan xing shi biao da ye jin you yi dian ma fan : $obj-decoded-string
  er she zhi you jian ti nei rong de cao zuo ze jue dui shi e meng -- wo men bu de bu gou jian yi ge Mail::Message::Body dui xiang lai fu gai xian you de 。 $obj-body(Mail::Message::Body-new(data = [split /\n/, $body]));
  Mail::Message chu li you jian de shi hou ke neng you dian man , ye zhe shi nan yong 。 ta de ti xi ye fei chang fu duo , shang mian wo men suo kan dao de zhe xie cao zuo jiu yi jing yong dao le 16 zhong lei (Mail::Address, Mail::Box::Parser, Mail::Box::Parser::Perl, Mail::Message, Mail::Message::Body, Mail::Message::Body::File, Mail::Message::Body::Lines, Mail::Message::Body::Multipart, Mail::Message::Body::Nested, Mail::Message::Construct, Mail::Message::Field, Mail::Message::Field::Fast, Mail::Message::Head, Mail::Message::Head::Complete, Mail::Message::Part, yi ji Mail::Reporter) he 4400 duo xing de dai ma 。 jin guan ta que shi yong you hen duo gong neng , wo huan shi sha sha de jiao de you jian de fen xi chu li ying gai geng wei jian jie 。 suo yi wo zuo xia lai jue ding zi ji zhe shou bian xie jin ke neng jian jie de you jian chu li han shu ku , jie guo jiu you le Email::Simple mo kuai , ta de jiao hu jie mian ru xia suo shi : my $obj = Email::Simple-new($rfc2822); my $subject = $obj-header("Subject"); $obj-header_set("Subject", "A new subject"); my $old_body = $obj-body; $obj-body_set("A new body\n"); print $obj-as_string;
  ta zuo de shi qing bing bu duo , dan que fei chang jian dan he gao xiao 。 ru guo ni xu yao MIME chu li , ke yi shi yong ta de zi lei Email::MIME, gai lei zeng jia le parts fang fa 。 shi ji shang , xuan ze na yi zhong you jian chu li han shu ku wan quan qu jue yu ni , zui zhong yong hu , bu guo bing bu zong shi zhe yang de 。 you xu duo fu zhu xing de mo kuai , bang zhu ni zai geng gao de ying yong ceng shang chu li you jian xin xi de , ke neng yao qiu ni ti gong te ding de you jian biao da dui xiang 。 bi ru zui jin de Mail::ListDetector mo kuai ( shao hou wo men jiang jie xi ), xu yao chuan gei ta de you jian wei Mail::Internet dui xiang , yin wei gai dui xiang de cao zuo jie mian (API) shi yi zhi de 。 er wo bu xiang yong Mail::Internet dui xiang , dan wo you xu yao Mail::ListDetector de yi xie gong neng , na wo ke yi zuo xie shen me ne ? wei le rang yong hu ye neng gou you zhe yang de xuan ze , wo xie le yi ge yong yu biao da shang mian ge ge mo kuai cao zuo jie mian de chou xiang ceng , jiao zuo Email::Abstract 。 gei chu shang mian ren he yi zhong lei xing de dui xiang , wo men dou ke yi shuo : my $subject = Email::Abstract-get_header($obj, "Subject"); Email::Abstract-set_header($obj, "Subject", "My new subject"); my $body = Email::Abstract-get_body($obj); Email::Abstract-set_body($message, "Hello\nTest message\n"); $rfc2822 = Email::Abstract-as_string($obj);
  Email::Abstract zhi dao ru he zai zhe xie zhu yao de you jian biao da dui xiang shang zuo xiang ying de cao zuo 。 ta ye chou xiang le gou zao you jian xiao xi de guo cheng , bing yuan xu ni tong guo lei fang fa cast lai gai bian you jian xiao xi dui xiang de cao zuo jie mian : my $obj = Email::Abstract-cast($rfc2822, "Mail::Internet");
  my $mm = Email::Abstract-cast($obj, "Mail::Message"); zhe yang shi de mo kuai de zuo zhe de yi shi yong “ jie kou yu xian wei zhi (interface-agnostic)” de fang shi lai zhuan xie you jian chu li han shu ku 。 wo hen gan xie Michael Stevens li ji zai Mail::ListDetector zhong shi yong le Email::Abstract 。 xian zai wo ke yi jiang Email::Simple dui xiang chuan di gei Mail::ListDetector le , er qie ta gong zuo de fei chang hao 。 Email::Abstract ye gei le wo men dui shang mian suo you zhe xie mo kuai zuo ji zhun ce shi (benchmarks) de ji hui 。 zhe li shi wo shi yong de ce shi dai ma : use Email::Abstract; my $message = do { local $/; ; }; my @classes = qw(Email::MIME Email::Simple MIME::Entity Mail::Internet Mail::Message); eval "require $_" or die $@ for @classes; use Benchmark; my %h; for my $class (@classes) { $h{$class} = sub { my $obj = Email::Abstract-cast($message, $class); Email::Abstract-get_header($obj, "Subject"); Email::Abstract-get_body($obj); Email::Abstract-set_header($obj, "Subject", "New Subject"); Email::Abstract-set_body($obj, "A completely new body"); Email::Abstract-as_string($obj); } } timethese(1000, \%h); __DATA__ ...
  wo ba yi feng duan xiao de you jian fang dao DATA bu fen zhong , bing yun xing xiang tong de cao zuo yi qian ci : gou zao yi ge xin de xiao xi dui xiang , du qu you jian tou , du qu you jian ti , bing jiang xiao xi nei rong zuo wei zi fu chuan fan hui 。 Benchmark: timing 1000 iterations of Email::MIME, Email::Simple, MIME::Entity, Mail::Internet, Mail::Message... Email::MIME: 10 wallclock secs ( 7.97 usr + 0.24 sys = 8.21 CPU) @ 121.80/s (n=1000) Email::Simple: 9 wallclock secs ( 7.49 usr + 0.05 sys = 7.54 CPU) @ 132.63/s (n=1000) MIME::Entity: 33 wallclock secs (23.76 usr + 0.35 sys = 24.11 CPU) @ 41.48/s (n=1000) Mail::Internet: 24 wallclock secs (17.34 usr + 0.30 sys = 17.64 CPU) @ 56.69/s (n=1000) Mail::Message: 20 wallclock secs (17.12 usr + 0.27 sys = 17.39 CPU) @ 57.50/s (n=1000)
  Perl dian zi you jian xiang mu que shi shi cheng gong de :Email::MIME he Email::Simple de yun xing su du cha bu duo shi dui shou de liang bei 。 ran er , wo men yao qiang tiao yi dian , zhe li suo zuo de ce shi dou shi fei chang di ji de , ru guo ni yao zuo ren he bi zhe li kan dao de geng jia fu duo de cao zuo , ni gai kao lv na xie lao de Mail:: mo kuai 。 you xiang de chu li dui yu dan du xin jian de chu li yi jing tan le hen duo le , rang wo men lai kan kan dui yi zu you jian huo zhe cun fang you jian de wen jian jia gai ru he chu li 。 wo men ti dao guo Mail::Box , ta jue dui shi chu li you jian wen jian jia de lao da , ta zhi chi ben di he yuan cheng de wen jian jia chu li , ke yi bian ji wen jian jia , yi ji zuo xiang ying de pai xu cao zuo deng deng 。 yao shi yong ta , wo men shou xian xu yao Mail::Box::Manager mo kuai , ta shi yong lai gou jian Mail::Box dui xiang de gong chang dui xiang 。 use Mail::Box::Manager my $mgr = Mail::Box::Manager-new;
  jie xia lai , wo men tong guo guan li qi lai da kai wen jian jia : my $folder = $mgr-open(folder = $folder_file);
  er xian zai , wo men ke yi huo qu ge ge du li de you jian biao da dui xiang (Mail::Message): for ($folder-messages) { print $_-subject,"\n"; }
  yu ci zui wei xiang jin de , wo xi huan yong de you xiang guan li qi huan shi Mail::Util de read_mbox han shu 。 ba Unix zhong mbox wen jian lu jing chuan di gei ta , ran hou fan hui yi xi lie de ni ming shu zu , mei ge ni ming shu zu dou biao shi yi ge you jian xiao xi , qi yuan su wei gai xiao xi de mei yi xing 。 ru ci yi lai , ta fei chang shi he Mail::Internet-new huo zhe xiang jin de : for (read_mbox($folder_file)) { my $obj = Mail::Internet-new($_); print $_-head-get("Subject"),"\n"; }
  zhe liang zhong zuo fa dou fei chang rong yi , bu guo si hu zai Mail::Util de jian jie xing he Mail::Box de gong neng shang huan you xie jian hua de yu di , yu shi dian zi you jian xiang mu zai ci ting zhi xia lai , zhe ci de jiao dian ji zhong zai Email::Folder he Email::LocalDelivery shang mian 。 Email::Folder ke yi chu li mbox he maildir ge shi de you jian wen jian jia , yi ji ji hua zhong geng duo qi ta ge shi , bing qie ta you fei chang jian jie de cao zuo jie mian : my $folder = Email::Folder-new($folder_file); for ($folder-messages) { print $_-header("Subject"),"\n"; }
  mo ren qing kuang , ta fan hui yi xi lie Email::Simple dui xiang yong yi biao da mei feng you jian , bu guo zhe ke yi tong guo pai sheng yi ge zi lei lai gai bian 。 li ru , ru guo wo men xiang yao yuan shi de RFC2822 ge shi de zi fu chuan , wo men ke yi zhe yang zuo : package Email::Folder::Raw; use base 'Email::Folder'; sub bless_message { my ($self, $rfc2822) = @_; return $rfc2822; }
  ke neng jiang lai wo men bu yong zai pai sheng yi ge zi lei , ran hou bless_message , er gai yong Email::Abstract-cast lai geng rong yi de gai bian dui you jian xiao xi de biao da fang shi 。 chu li wen jian jia de ling yi fang mian jiu shi ru he xie shu ju le 。 huo zhe shuo ru he ben di tou di 。Email::LocalDelivery mo kuai de chu xian shi wei le fu zhu Email::Filter 。 wen ti bi ting qi lai yao geng nan xie , yin wei ta bi xu chu li suo ding , tiao kai you jian ti , yi ji you mailbox he maildir deng bu tong ge shi er yin fa de wen ti 。 er LocalDelivery ze tong guo jian dan de jie mian ba suo you zhe xie dou yin cang qi lai : Email::LocalDelivery-deliver($rfc2822, @mailboxes);
  Email::LocalDelivery he Email::Folder dou shi yong le Email::FolderType mo kuai lai bang zhu que ding shi na zhong lei xing de you jian wen jian jia ( tong guo wen jian ming lai pan duan )。 you jian di zhi de chu li wo men zai ci cong chou xiang ceng mian hui dao di ji de chu li , you da liang de mo kuai ke yong yu dui you jian di zhi de chu li 。 wo hen xi huan lao de Mail::Address mo kuai 。 you jian di zhi ke yi fen ge wei ge zhong zi duan , zhu ru : shi ji de you jian di zhi , ming cheng duan yu , zhu shi xin xi 。 li ru : Example user (Not a real user)
  Mail::Address jie xi zhe xie you jian di zhi , bing jiang ming cheng duan yu he zhu shi fen li chu lai , yi bian huo qu ge ge du li de bu fen : for (Mail::Address-parse($from_line)) { print $_-name, "\t", $_-address, "\n"; }
  bu xing de shi , he qi ta hen duo you jian mo kuai yi yang , bing bu zhen de na me you yong 。 my ($addr) = Mail::Address-parse('"eBay, Inc." '); print $addr-name # Inc. eBay
  de dao de jie guo reng ran nan yi rang ren jie shou , sui ran ta bi zhi jian de ban ben suo fan hui de "Inc Ebay" yao hao xie 。 yu shi Casey West jia ru wo men bing chuang zao le Email::Address mo kuai 。 ta he Mail::Address shi yong yi zhi de jiao hu jie mian , bing qie yun xing di geng jia kuai su , cha bu duo liang dao san bei 。( yi zhu : shang mian de li zi zhong ,Email::Address fan hui "eBay, Inc." 。 kan lai zai zuo zhe yan li ,Mail::Address de zuo zhe hua she tian zu le 。) huan you yi jian wo men jing chang xu yao zuo de shi qing jiu shi xiao yan you jian di zhi shi fou he fa 。 bi ru , mou ge yong hu zai zhan dian shang zhu ce , wo men jiu xu yao dui ta suo ti gong de you jian di zhi shi fou neng gou jie shou you jian zuo jian cha 。Email::Valid mo kuai shi zai wo men zhe bang pan ni de ren chong jin lai zhi qian , jiu yi you de Email:: ming zi kong jian de yuan zhu min , zhe ge mo kuai jiu shi yong lai zuo zhe jian shi qing de 。 zai ta zui jian yue de yong fa zhong , wo men ke yi shuo : if (not Email::Valid-address('test@example.com')) { die "Not a valid address" }
  ni ye ke yi da kai qi ta jian cha de xuan xiang , bi ru que ding ta de yu ming yong you yi ge he fa de MX ji lu , xiu zheng chang jian de AOL he Compuserve de you jian di zhi de yi xie cuo wu , ru xia : if (not Email::Valid-address(-address = 'test@example.com', -mxcheck = 1)) { die "Not a valid address" }
  you jian shu ju zhuan huan wo men you le zi ji de xin jian , jie xia lai hui dui ta men zuo xie shen me ne ? wo fa xian da duo shi dui you jian jin xing wen ben hua fen xi , zhe li you san ge mo kuai ke yi xie zhu wo men : shou xian shi Text::Quoted , ta huo qu you jian ti de wen ben , shi ji shang ke yi shi ren he qi ta wen ben , ran hou chang shi zhao chu mou xie yin yong qi ta you jian de wen ben bu fen , ran hou jiang zhi fen li bing bao cun dao qian tao de shu ju jie gou zhong 。 li ru , ru guo wo men you $message = foo # Bar baz quux EOF
  ran hou yun xing extract($message) jiu hui fan hui ru xia de shu ju jie gou : [ [ { text = 'foo', quoter = '', raw = ' foo' }, [ { text = 'Bar', quoter = ' #', raw = ' # Bar' } ], { text = 'baz', quoter = '', raw = ' baz' } ], { empty = 1 }, { text = 'quux', quoter = '', raw = 'quux' } ];
  dang ni xian shi you jian xiao xi de nei rong shi , zhun bei yong bu tong de yan se lai qu fen bu tong de yin yong wen ben , na me zhe ge mo kuai jiu bang dao ni da mang le 。 lei si gai nian de huan you Text::Original mo kuai , yong yu sou xun yi yuan shi wen jian nei rong kai tou , mei you bei yin yong de bu fen 。 ta zhi dao ru he shi bie ge zhong lei xing de shu xing xing , suo yi you : $message = Why are there so many different mail modules? There's more than one way to do it! Different modules have different focuses, and operate at different levels; some lower, some higher. EOF
  na me first_sentence($message) jiang fan hui There's more than one way to do it!。Mariachi you jian lie biao cun dang cheng xu jiu shi yong le zhe xiang ji shu , wei yi ge xian suo zhong de you jian gei chu ta de ti bai 。 shuo dao you jian de xian suo hua ,Mail::Thread mo kuai shi xian le Jamie Zawinski de you jian xian suo hua suan fa , gai suan fa xian shi bei Mozilla suo yong , ji er xu duo qi ta you jian ke hu duan ye kai shi shi yong zhe zhong ji shu 。 dang ran Mariachi ye shi yong le zhe xiang ji shu , zui jin ta huan zuo le geng xin , shi yong Email::Abstract lai chu li ge zhong ni reng guo qu de you jian biao da dui xiang : my $threader = Mail::Thread-new(@mails); $threader-thread; # ji suan xian suo for ($threader-rootset) { # zai yi ge xian suo nei de yuan shi you jian dump_thread($_); }
  you jian guo lv jing dian de Perl de you jian guo lv gong ju mo bu jiu shi Mail::Audit le , wo huan zai zhe li xie guo guan yu ru he shi yong Mail::Audit mo kuai de wen zhang (http://www.perl.com/pub/a/2001/07/17/mailfiltering.html), yi ji ru he yu Mail::SpamAssassin (http://www.perl.com/pub/a/2002/03/06/spam.html) mo kuai xiang jie he shi yong 。 wo men yi jing ti dao guo Mail::ListDetector mo kuai hao ji ci le 。 wo ba ta he Mail::Audit jie he zai yi qi shi yong , bang zhu zi ji zuo le da liang de zi dong you jian guo lv gong zuo 。Mail::Audit::List de cha jian shi yong ListDetector lai cha zhao xin jian zhong de you jian lie biao tou xin xi , zhu ru List-Id,X-Mailman-Version deng deng lei si de dong xi , zhe xie tou xin xi ke yi bang zhu pan bie gai you jian shi fou lai zi yu you jian lie biao 。 zhe yi wei zhe wo you neng li guo lv suo you lai zi you jian lie biao de xin jian dao ge zi de wen jian jia zhong , jiu xiang zhe yang : my $list = Mail::ListDetector-new($obj); if ($list) { my $name = $list-listname; $item-accept("mail/$name.-$date"); }
  ran er ,Mail::Audit ben shen huan you hen chang yi duan lu yao zou , suo yi ru guo ni xin jia she de xi tong de hua , wo men gu li nin shi yong dian zi you jian xiang mu de Email::Filter mo kuai zuo wei ti dai , ta men de da bu fen cao zuo jie mian shi yi zhi de , jin guan gong neng bing bu wan quan xiang tong 。 wei le zhui qiu jian jie he su du , ta shi yong le xin shi de Email::Simple zuo wei you jian biao da dui xiang mo kuai 。 you jian xin xi wa jue zui hou , wo suo zuo de bi jiao gao ji de shi qing jiu shi kai fa yi ge zi dong fen lei , zu zhi , bing suo yin you jian dao shu ju ku de ying yong kuang jia , bing chang shi cong zhong fen xi bing ti qu you jia zhi de xin xi 。 wo de di yi ge wan cheng zhe ge yu qi mu biao de mo kuai shi Mail::Miner , ta you san ge zhu yao bu fen zu cheng 。 di yi ge bu fen huo qu yi feng you jian hou , qu chu ge zhong fu jian , bing fen bie cun chu dao shu ju ku 。 di er bu fen zong lan zhe feng you jian bing yun xing yi xi lie de shi bie (Recogniser) mo kuai , ru ci sou xun you jian di zhi , dian hua hao ma , yi xie guan jian zi he duan yu deng deng , bing ba ta men cun chu dao ling yi ge du li de shu ju ku biao zhong 。 di san bu fen wei ming ling xing gong ju , yong lai cha xun shu ju ku zhong de you jian yi ji xiang guan de xin xi 。 ju ge li zi , ru guo wo xu yao zhao Tim O'Reilly de you zheng di zhi , wo jiu hui shi yong cha xun gong ju mm , cong ta fa lai de xin zhong zhao chu gai di zhi : % mm --from "Tim O" --address Address found in message 1835 from "Tim O'Reilly" : Tim O'Reilly @ O'Reilly %26amp; Associates, Inc. 1005 Gravenstein Highway North, Sebastopol, CA 95472
  ru guo yao huo qu wan zheng de you jian , wo ke yi shuo % mm --id 1835
  ru guo ta yuan ben bao han yi ge fu jian , na me wo men ke neng hui kan dao lei si xia mian de bu fen : [ text/xml attachment something.xml detached - use mm --detach 208 to recover ]
  wo nian tie zhong jian de na yi xing mm --detach 208 dao shell zhong , ran hou hen kuai de ,something.xml xie dao le ci pan shang 。 xian zai Mail::Miner yi jing fei chang bu cuo le , bu guo ta ba san zhong si xiang jin jin di kun bang zai yi ge bao zhong -- you jian de gui dang , you jian de shu ju wa jue yi ji cha xun shu ju ku de ming ling xing jie mian -- zhe shi de hen nan dan du kai fa huo zhe kuo zhan mei kuai de gong neng 。 dang ran , ta shi yong le lao shi de Mail:: ming zi kong jian 。 zhe yin ling wo men zou dao zhe ci you jian mo kuai lv cheng de zui hou yi zhan , zui xin fa bu de :Email::Store mo kuai 。 zhe shi ge ji yu Class::DBI de ying yong kuang jia , yong lai cun chu you jian dao shu ju ku bing yi ge zhong fang shi suo yin : use Email::Store 'dbi:SQLite:mail.db'; Email::Store-setup; Email::Store::Mail-store($rfc2822);
  jin jie zhe ... my ($name) = Email::Store::Name-search( name = "Simon Cozens" ) @mails_from_simon = $name-addressings( role = "From" )-mails;
  ta ke yi yong lai gou jian lei si Mariachi de you jian lie biao gui dang gong ju , huo zhe lei si Mail::Miner de shu ju wa jue 。 ta reng ran zai chu bu de kai fa jie duan , bing zai zeng qiang mo kuai de kuo zhan xing fang mian shi yong le yi xie xin de si xiang 。 zai wo men shi yong Email::Store xie chu di yi ge you jian gui dang he sou suo gong ju de shi hou , wo hui zai ci gei da jia zuo xiang xi jie shao de 。 zhe ye shi wei le perl.org de xin de Perl you jian lie biao chu li jie kou er zhun bei zuo de gong zuo 。 xiao jie wo men yi jing kan guo le CPAN shang de ji ge zhu yao de you jian chu li mo kuai , dang ran huan you geng duo 。 hen ming xian de , wo zhe shi pian tan na xie zi ji xie de mo kuai 。 te ding de Perl dian zi you jian xiang mu de mo kuai ze shi yong Email::* de ming zi kong jian 。 wo men te bie she ji le zhe xie jian jie 、 gao xiao de mo kuai , er ta men bing bu zong shi lao shi de Mail::* mo kuai de you liang ti huan fang an , te bie xiang Mail::Box zhi lei 。 dao ci , wo xi wang ge wei tong guo dui ben wen de yue du , le jie he ren shi geng duo de you jian chu li gong ju mo kuai , bing zai zhi hou shi yong Perl lai chu li you jian shi , xiong zhong you qiu he 。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

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

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

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

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

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

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

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

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

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

 
 
yi zhe / zuo zhe :chunzi chu chu : zhong guo Perl xie hui FPC(Foundation of Perlchina) yuan ming :The Evolution of Perl Email Handling zuo zhe :Simon Cozens yuan wen :http://www.perl.com/pub/a/2004/06/10/email.html fa biao :June 10, 2004 qing bao hu zuo zhe de zhu zuo quan , wei hu zuo zhe lao dong de jie jing 。 mei tian wo dou yao hua fei da liang de shi jian zai dian zi you jian xiang guan de gong zuo shang , huo zhe tong guo you jian lai he qi ta gong zuo huo ban lian xi , huo zhe rao you xing zhi di fen xi , suo yin , chong xin zu zhi yi ji wa jue you jian nei rong 。 hen zi ran de ,Perl xie zhu wo zuo zhe xie shi qing 。 zai CPAN shang you hen duo xian cheng de mo kuai ke yi yong lai chu li dian zi you jian , wo men jiang jie shao qi zhong ji ge zhu yao de 。 tong shi wo men ye jiang guan zhu you wo he Richard Clamp,Simon Wistow yi ji qi ta huo ban suo zhi li de Perl dian zi you jian xiang mu (Perl Email Project), gai xiang mu de mu biao shi ti gong yi xi lie jian dan de , you xiao de , jing zhun de you jian chu li mo kuai 。 you jian xiao xi de chu li wo men cong yi xie bi jiao jian dan de , yong lai miao hui yi feng dan du you jian , ti gong dui you jian tou he you jian ti de fang wen , shen zhi xiu gai ta men de xin xi de na xie mo kuai kai shi jie shao 。 suo you de zhe xie mo kuai de zeng zu fu dou shi Mail::Internet , you Graham Barr chuang jian , mu qian Mark Overmeer zai wei hu 。 gai mo kuai ti gong le tong guo shu zu ( yuan su wei zi fu chuan xing ) huo zhe wen jian ju bing lai du qu xin jian nei rong de gou zao qi , bing tong guo ta fan hui yi ge miao shu gai xin jian de Mail::Internet dui xiang 。 zai xia mian de li zi zhong , wo men shi yong bian liang $rfc2822 lai biao shi zi fu chuan xing shi de you jian xin xi nei rong 。 my $obj = Mail::Internet-new( [ split /\n/, $rfc2822 ] ); Mail::Internet cong xin jian zhong ti qu gou zao chu yi ge you jian tou dui xiang , bing lian dai you jian ti xin xi 。 you jian tou dui xiang de lei wei Mail::Header 。 ni ke yi tong guo gai dui xiang huo qu huo zhe she zhi you jian tou de xin xi : my $subject = $obj-head-get("Subject"); $obj-head-replace("Subject", "New subject"); er du qu huo zhe bian ji you jian ti nei rong de cao zuo , ze ke yi shi yong body fang fa : my $old_body = $obj-body; $obj-body("Wasn't worth reading anyway."); dao xian zai wei zhi wo huan mei you ti dao guo ren he guan yu MIME de dong xi 。 dui yu jian dan de ren wu lai shuo ,Mail::Internet que shi fei chang fang bian , bu guo ta bing bu wan quan zhi chi dui MIME de chu li 。 xie tian xie di ,MIME::Entity zuo wei yi ge wei MIME er kao lv she ji de Mail::Internet zi lei , yuan xu ni du qu MIME xiao xi de mei yi ge du li de bu fen (part): my $num_parts = $obj-parts; for (0..$num_parts) { my $part = $obj-parts($_); ... } ru guo Mail::Internet he MIME::Entity dou bu shi he ni , ni ke yi shi shi Mark Overmeer zi ji de Mail::Message mo kuai , gai mo kuai shi ling ren yin xiang shen ke de Mail::Box mo kuai zhong de yi bu fen 。Mail::Message shi ge ji fu te se de 、 gong neng quan mian de mo kuai , dan zhe xie you dian bing bu zong yi wei zhe bao yang 。 Mail::Message dui xiang tong chang dou shi zai Mail::Box du qu yi ge dian zi you jian wen jian jia de shi hou , zai nei bu gou jian de 。 dang ran ta ye ke yi tong guo read fang fa lai du qu yi feng xin jian : $obj = Mail::Message-read($rfc2822); jiu xiang Mail::Internet yi yang , you jian xiao xi bei fen ge wei you jian tou he you jian ti , er yu Mail::Internet bu tong de shi , you jian ti ye shi yi ge dui xiang 。 wo men ru ci du qu you jian tou : $obj-head-get("Subject"); huo zhe , ru guo shi Subject tou xin xi yi ji qi ta chang jian de you jian tou xin xi , ke yi ru ci du qu : $obj-subject; wo zhao bu dao zhi jie she zhi tou xin xi de fang fa , suo yi zui zhong ke neng xu yao zhe yang zuo : $obj-head-delete($header); $obj-head-add($header, $_) for @data; du qu you jian ti nei rong zuo wei zi fu chuan xing shi biao da ye jin you yi dian ma fan : $obj-decoded-string er she zhi you jian ti nei rong de cao zuo ze jue dui shi e meng -- wo men bu de bu gou jian yi ge Mail::Message::Body dui xiang lai fu gai xian you de 。 $obj-body(Mail::Message::Body-new(data = [split /\n/, $body])); Mail::Message chu li you jian de shi hou ke neng you dian man , ye zhe shi nan yong 。 ta de ti xi ye fei chang fu duo , shang mian wo men suo kan dao de zhe xie cao zuo jiu yi jing yong dao le 16 zhong lei (Mail::Address, Mail::Box::Parser, Mail::Box::Parser::Perl, Mail::Message, Mail::Message::Body, Mail::Message::Body::File, Mail::Message::Body::Lines, Mail::Message::Body::Multipart, Mail::Message::Body::Nested, Mail::Message::Construct, Mail::Message::Field, Mail::Message::Field::Fast, Mail::Message::Head, Mail::Message::Head::Complete, Mail::Message::Part, yi ji Mail::Reporter) he 4400 duo xing de dai ma 。 jin guan ta que shi yong you hen duo gong neng , wo huan shi sha sha de jiao de you jian de fen xi chu li ying gai geng wei jian jie 。 suo yi wo zuo xia lai jue ding zi ji zhe shou bian xie jin ke neng jian jie de you jian chu li han shu ku , jie guo jiu you le Email::Simple mo kuai , ta de jiao hu jie mian ru xia suo shi : my $obj = Email::Simple-new($rfc2822); my $subject = $obj-header("Subject"); $obj-header_set("Subject", "A new subject"); my $old_body = $obj-body; $obj-body_set("A new body\n"); print $obj-as_string; ta zuo de shi qing bing bu duo , dan que fei chang jian dan he gao xiao 。 ru guo ni xu yao MIME chu li , ke yi shi yong ta de zi lei Email::MIME, gai lei zeng jia le parts fang fa 。 shi ji shang , xuan ze na yi zhong you jian chu li han shu ku wan quan qu jue yu ni , zui zhong yong hu , bu guo bing bu zong shi zhe yang de 。 you xu duo fu zhu xing de mo kuai , bang zhu ni zai geng gao de ying yong ceng shang chu li you jian xin xi de , ke neng yao qiu ni ti gong te ding de you jian biao da dui xiang 。 bi ru zui jin de Mail::ListDetector mo kuai ( shao hou wo men jiang jie xi ), xu yao chuan gei ta de you jian wei Mail::Internet dui xiang , yin wei gai dui xiang de cao zuo jie mian (API) shi yi zhi de 。 er wo bu xiang yong Mail::Internet dui xiang , dan wo you xu yao Mail::ListDetector de yi xie gong neng , na wo ke yi zuo xie shen me ne ? wei le rang yong hu ye neng gou you zhe yang de xuan ze , wo xie le yi ge yong yu biao da shang mian ge ge mo kuai cao zuo jie mian de chou xiang ceng , jiao zuo Email::Abstract 。 gei chu shang mian ren he yi zhong lei xing de dui xiang , wo men dou ke yi shuo : my $subject = Email::Abstract-get_header($obj, "Subject"); Email::Abstract-set_header($obj, "Subject", "My new subject"); my $body = Email::Abstract-get_body($obj); Email::Abstract-set_body($message, "Hello\nTest message\n"); $rfc2822 = Email::Abstract-as_string($obj); Email::Abstract zhi dao ru he zai zhe xie zhu yao de you jian biao da dui xiang shang zuo xiang ying de cao zuo 。 ta ye chou xiang le gou zao you jian xiao xi de guo cheng , bing yuan xu ni tong guo lei fang fa cast lai gai bian you jian xiao xi dui xiang de cao zuo jie mian : my $obj = Email::Abstract-cast($rfc2822, "Mail::Internet"); my $mm = Email::Abstract-cast($obj, "Mail::Message"); zhe yang shi de mo kuai de zuo zhe de yi shi yong “ jie kou yu xian wei zhi (interface-agnostic)” de fang shi lai zhuan xie you jian chu li han shu ku 。 wo hen gan xie Michael Stevens li ji zai Mail::ListDetector zhong shi yong le Email::Abstract 。 xian zai wo ke yi jiang Email::Simple dui xiang chuan di gei Mail::ListDetector le , er qie ta gong zuo de fei chang hao 。 Email::Abstract ye gei le wo men dui shang mian suo you zhe xie mo kuai zuo ji zhun ce shi (benchmarks) de ji hui 。 zhe li shi wo shi yong de ce shi dai ma : use Email::Abstract; my $message = do { local $/; ; }; my @classes = qw(Email::MIME Email::Simple MIME::Entity Mail::Internet Mail::Message); eval "require $_" or die $@ for @classes; use Benchmark; my %h; for my $class (@classes) { $h{$class} = sub { my $obj = Email::Abstract-cast($message, $class); Email::Abstract-get_header($obj, "Subject"); Email::Abstract-get_body($obj); Email::Abstract-set_header($obj, "Subject", "New Subject"); Email::Abstract-set_body($obj, "A completely new body"); Email::Abstract-as_string($obj); } } timethese(1000, \%h); __DATA__ ... wo ba yi feng duan xiao de you jian fang dao DATA bu fen zhong , bing yun xing xiang tong de cao zuo yi qian ci : gou zao yi ge xin de xiao xi dui xiang , du qu you jian tou , du qu you jian ti , bing jiang xiao xi nei rong zuo wei zi fu chuan fan hui 。 Benchmark: timing 1000 iterations of Email::MIME, Email::Simple, MIME::Entity, Mail::Internet, Mail::Message... Email::MIME: 10 wallclock secs ( 7.97 usr + 0.24 sys = 8.21 CPU) @ 121.80/s (n=1000) Email::Simple: 9 wallclock secs ( 7.49 usr + 0.05 sys = 7.54 CPU) @ 132.63/s (n=1000) MIME::Entity: 33 wallclock secs (23.76 usr + 0.35 sys = 24.11 CPU) @ 41.48/s (n=1000) Mail::Internet: 24 wallclock secs (17.34 usr + 0.30 sys = 17.64 CPU) @ 56.69/s (n=1000) Mail::Message: 20 wallclock secs (17.12 usr + 0.27 sys = 17.39 CPU) @ 57.50/s (n=1000) Perl dian zi you jian xiang mu que shi shi cheng gong de :Email::MIME he Email::Simple de yun xing su du cha bu duo shi dui shou de liang bei 。 ran er , wo men yao qiang tiao yi dian , zhe li suo zuo de ce shi dou shi fei chang di ji de , ru guo ni yao zuo ren he bi zhe li kan dao de geng jia fu duo de cao zuo , ni gai kao lv na xie lao de Mail:: mo kuai 。 you xiang de chu li dui yu dan du xin jian de chu li yi jing tan le hen duo le , rang wo men lai kan kan dui yi zu you jian huo zhe cun fang you jian de wen jian jia gai ru he chu li 。 wo men ti dao guo Mail::Box , ta jue dui shi chu li you jian wen jian jia de lao da , ta zhi chi ben di he yuan cheng de wen jian jia chu li , ke yi bian ji wen jian jia , yi ji zuo xiang ying de pai xu cao zuo deng deng 。 yao shi yong ta , wo men shou xian xu yao Mail::Box::Manager mo kuai , ta shi yong lai gou jian Mail::Box dui xiang de gong chang dui xiang 。 use Mail::Box::Manager my $mgr = Mail::Box::Manager-new; jie xia lai , wo men tong guo guan li qi lai da kai wen jian jia : my $folder = $mgr-open(folder = $folder_file); er xian zai , wo men ke yi huo qu ge ge du li de you jian biao da dui xiang (Mail::Message): for ($folder-messages) { print $_-subject,"\n"; } yu ci zui wei xiang jin de , wo xi huan yong de you xiang guan li qi huan shi Mail::Util de read_mbox han shu 。 ba Unix zhong mbox wen jian lu jing chuan di gei ta , ran hou fan hui yi xi lie de ni ming shu zu , mei ge ni ming shu zu dou biao shi yi ge you jian xiao xi , qi yuan su wei gai xiao xi de mei yi xing 。 ru ci yi lai , ta fei chang shi he Mail::Internet-new huo zhe xiang jin de : for (read_mbox($folder_file)) { my $obj = Mail::Internet-new($_); print $_-head-get("Subject"),"\n"; } zhe liang zhong zuo fa dou fei chang rong yi , bu guo si hu zai Mail::Util de jian jie xing he Mail::Box de gong neng shang huan you xie jian hua de yu di , yu shi dian zi you jian xiang mu zai ci ting zhi xia lai , zhe ci de jiao dian ji zhong zai Email::Folder he Email::LocalDelivery shang mian 。 Email::Folder ke yi chu li mbox he maildir ge shi de you jian wen jian jia , yi ji ji hua zhong geng duo qi ta ge shi , bing qie ta you fei chang jian jie de cao zuo jie mian : my $folder = Email::Folder-new($folder_file); for ($folder-messages) { print $_-header("Subject"),"\n"; } mo ren qing kuang , ta fan hui yi xi lie Email::Simple dui xiang yong yi biao da mei feng you jian , bu guo zhe ke yi tong guo pai sheng yi ge zi lei lai gai bian 。 li ru , ru guo wo men xiang yao yuan shi de RFC2822 ge shi de zi fu chuan , wo men ke yi zhe yang zuo : package Email::Folder::Raw; use base 'Email::Folder'; sub bless_message { my ($self, $rfc2822) = @_; return $rfc2822; } ke neng jiang lai wo men bu yong zai pai sheng yi ge zi lei , ran hou bless_message , er gai yong Email::Abstract-cast lai geng rong yi de gai bian dui you jian xiao xi de biao da fang shi 。 chu li wen jian jia de ling yi fang mian jiu shi ru he xie shu ju le 。 huo zhe shuo ru he ben di tou di 。Email::LocalDelivery mo kuai de chu xian shi wei le fu zhu Email::Filter 。 wen ti bi ting qi lai yao geng nan xie , yin wei ta bi xu chu li suo ding , tiao kai you jian ti , yi ji you mailbox he maildir deng bu tong ge shi er yin fa de wen ti 。 er LocalDelivery ze tong guo jian dan de jie mian ba suo you zhe xie dou yin cang qi lai : Email::LocalDelivery-deliver($rfc2822, @mailboxes); Email::LocalDelivery he Email::Folder dou shi yong le Email::FolderType mo kuai lai bang zhu que ding shi na zhong lei xing de you jian wen jian jia ( tong guo wen jian ming lai pan duan )。 you jian di zhi de chu li wo men zai ci cong chou xiang ceng mian hui dao di ji de chu li , you da liang de mo kuai ke yong yu dui you jian di zhi de chu li 。 wo hen xi huan lao de Mail::Address mo kuai 。 you jian di zhi ke yi fen ge wei ge zhong zi duan , zhu ru : shi ji de you jian di zhi , ming cheng duan yu , zhu shi xin xi 。 li ru : Example user (Not a real user) Mail::Address jie xi zhe xie you jian di zhi , bing jiang ming cheng duan yu he zhu shi fen li chu lai , yi bian huo qu ge ge du li de bu fen : for (Mail::Address-parse($from_line)) { print $_-name, "\t", $_-address, "\n"; } bu xing de shi , he qi ta hen duo you jian mo kuai yi yang , bing bu zhen de na me you yong 。 my ($addr) = Mail::Address-parse('"eBay, Inc." '); print $addr-name # Inc. eBay de dao de jie guo reng ran nan yi rang ren jie shou , sui ran ta bi zhi jian de ban ben suo fan hui de "Inc Ebay" yao hao xie 。 yu shi Casey West jia ru wo men bing chuang zao le Email::Address mo kuai 。 ta he Mail::Address shi yong yi zhi de jiao hu jie mian , bing qie yun xing di geng jia kuai su , cha bu duo liang dao san bei 。( yi zhu : shang mian de li zi zhong ,Email::Address fan hui "eBay, Inc." 。 kan lai zai zuo zhe yan li ,Mail::Address de zuo zhe hua she tian zu le 。) huan you yi jian wo men jing chang xu yao zuo de shi qing jiu shi xiao yan you jian di zhi shi fou he fa 。 bi ru , mou ge yong hu zai zhan dian shang zhu ce , wo men jiu xu yao dui ta suo ti gong de you jian di zhi shi fou neng gou jie shou you jian zuo jian cha 。Email::Valid mo kuai shi zai wo men zhe bang pan ni de ren chong jin lai zhi qian , jiu yi you de Email:: ming zi kong jian de yuan zhu min , zhe ge mo kuai jiu shi yong lai zuo zhe jian shi qing de 。 zai ta zui jian yue de yong fa zhong , wo men ke yi shuo : if (not Email::Valid-address('test@example.com')) { die "Not a valid address" } ni ye ke yi da kai qi ta jian cha de xuan xiang , bi ru que ding ta de yu ming yong you yi ge he fa de MX ji lu , xiu zheng chang jian de AOL he Compuserve de you jian di zhi de yi xie cuo wu , ru xia : if (not Email::Valid-address(-address = 'test@example.com', -mxcheck = 1)) { die "Not a valid address" } you jian shu ju zhuan huan wo men you le zi ji de xin jian , jie xia lai hui dui ta men zuo xie shen me ne ? wo fa xian da duo shi dui you jian jin xing wen ben hua fen xi , zhe li you san ge mo kuai ke yi xie zhu wo men : shou xian shi Text::Quoted , ta huo qu you jian ti de wen ben , shi ji shang ke yi shi ren he qi ta wen ben , ran hou chang shi zhao chu mou xie yin yong qi ta you jian de wen ben bu fen , ran hou jiang zhi fen li bing bao cun dao qian tao de shu ju jie gou zhong 。 li ru , ru guo wo men you $message = foo # Bar baz quux EOF ran hou yun xing extract($message) jiu hui fan hui ru xia de shu ju jie gou : [ [ { text = 'foo', quoter = '', raw = ' foo' }, [ { text = 'Bar', quoter = ' #', raw = ' # Bar' } ], { text = 'baz', quoter = '', raw = ' baz' } ], { empty = 1 }, { text = 'quux', quoter = '', raw = 'quux' } ]; dang ni xian shi you jian xiao xi de nei rong shi , zhun bei yong bu tong de yan se lai qu fen bu tong de yin yong wen ben , na me zhe ge mo kuai jiu bang dao ni da mang le 。 lei si gai nian de huan you Text::Original mo kuai , yong yu sou xun yi yuan shi wen jian nei rong kai tou , mei you bei yin yong de bu fen 。 ta zhi dao ru he shi bie ge zhong lei xing de shu xing xing , suo yi you : $message = Why are there so many different mail modules? There's more than one way to do it! Different modules have different focuses, and operate at different levels; some lower, some higher. EOF na me first_sentence($message) jiang fan hui There's more than one way to do it!。Mariachi you jian lie biao cun dang cheng xu jiu shi yong le zhe xiang ji shu , wei yi ge xian suo zhong de you jian gei chu ta de ti bai 。 shuo dao you jian de xian suo hua ,Mail::Thread mo kuai shi xian le Jamie Zawinski de you jian xian suo hua suan fa , gai suan fa xian shi bei Mozilla suo yong , ji er xu duo qi ta you jian ke hu duan ye kai shi shi yong zhe zhong ji shu 。 dang ran Mariachi ye shi yong le zhe xiang ji shu , zui jin ta huan zuo le geng xin , shi yong Email::Abstract lai chu li ge zhong ni reng guo qu de you jian biao da dui xiang : my $threader = Mail::Thread-new(@mails); $threader-thread; # ji suan xian suo for ($threader-rootset) { # zai yi ge xian suo nei de yuan shi you jian dump_thread($_); } you jian guo lv jing dian de Perl de you jian guo lv gong ju mo bu jiu shi Mail::Audit le , wo huan zai zhe li xie guo guan yu ru he shi yong Mail::Audit mo kuai de wen zhang (http://www.perl.com/pub/a/2001/07/17/mailfiltering.html), yi ji ru he yu Mail::SpamAssassin (http://www.perl.com/pub/a/2002/03/06/spam.html) mo kuai xiang jie he shi yong 。 wo men yi jing ti dao guo Mail::ListDetector mo kuai hao ji ci le 。 wo ba ta he Mail::Audit jie he zai yi qi shi yong , bang zhu zi ji zuo le da liang de zi dong you jian guo lv gong zuo 。Mail::Audit::List de cha jian shi yong ListDetector lai cha zhao xin jian zhong de you jian lie biao tou xin xi , zhu ru List-Id,X-Mailman-Version deng deng lei si de dong xi , zhe xie tou xin xi ke yi bang zhu pan bie gai you jian shi fou lai zi yu you jian lie biao 。 zhe yi wei zhe wo you neng li guo lv suo you lai zi you jian lie biao de xin jian dao ge zi de wen jian jia zhong , jiu xiang zhe yang : my $list = Mail::ListDetector-new($obj); if ($list) { my $name = $list-listname; $item-accept("mail/$name.-$date"); } ran er ,Mail::Audit ben shen huan you hen chang yi duan lu yao zou , suo yi ru guo ni xin jia she de xi tong de hua , wo men gu li nin shi yong dian zi you jian xiang mu de Email::Filter mo kuai zuo wei ti dai , ta men de da bu fen cao zuo jie mian shi yi zhi de , jin guan gong neng bing bu wan quan xiang tong 。 wei le zhui qiu jian jie he su du , ta shi yong le xin shi de Email::Simple zuo wei you jian biao da dui xiang mo kuai 。 you jian xin xi wa jue zui hou , wo suo zuo de bi jiao gao ji de shi qing jiu shi kai fa yi ge zi dong fen lei , zu zhi , bing suo yin you jian dao shu ju ku de ying yong kuang jia , bing chang shi cong zhong fen xi bing ti qu you jia zhi de xin xi 。 wo de di yi ge wan cheng zhe ge yu qi mu biao de mo kuai shi Mail::Miner , ta you san ge zhu yao bu fen zu cheng 。 di yi ge bu fen huo qu yi feng you jian hou , qu chu ge zhong fu jian , bing fen bie cun chu dao shu ju ku 。 di er bu fen zong lan zhe feng you jian bing yun xing yi xi lie de shi bie (Recogniser) mo kuai , ru ci sou xun you jian di zhi , dian hua hao ma , yi xie guan jian zi he duan yu deng deng , bing ba ta men cun chu dao ling yi ge du li de shu ju ku biao zhong 。 di san bu fen wei ming ling xing gong ju , yong lai cha xun shu ju ku zhong de you jian yi ji xiang guan de xin xi 。 ju ge li zi , ru guo wo xu yao zhao Tim O'Reilly de you zheng di zhi , wo jiu hui shi yong cha xun gong ju mm , cong ta fa lai de xin zhong zhao chu gai di zhi : % mm --from "Tim O" --address Address found in message 1835 from "Tim O'Reilly" : Tim O'Reilly @ O'Reilly %26amp; Associates, Inc. 1005 Gravenstein Highway North, Sebastopol, CA 95472 ru guo yao huo qu wan zheng de you jian , wo ke yi shuo % mm --id 1835 ru guo ta yuan ben bao han yi ge fu jian , na me wo men ke neng hui kan dao lei si xia mian de bu fen : [ text/xml attachment something.xml detached - use mm --detach 208 to recover ] wo nian tie zhong jian de na yi xing mm --detach 208 dao shell zhong , ran hou hen kuai de ,something.xml xie dao le ci pan shang 。 xian zai Mail::Miner yi jing fei chang bu cuo le , bu guo ta ba san zhong si xiang jin jin di kun bang zai yi ge bao zhong -- you jian de gui dang , you jian de shu ju wa jue yi ji cha xun shu ju ku de ming ling xing jie mian -- zhe shi de hen nan dan du kai fa huo zhe kuo zhan mei kuai de gong neng 。 dang ran , ta shi yong le lao shi de Mail:: ming zi kong jian 。 zhe yin ling wo men zou dao zhe ci you jian mo kuai lv cheng de zui hou yi zhan , zui xin fa bu de :Email::Store mo kuai 。 zhe shi ge ji yu Class::DBI de ying yong kuang jia , yong lai cun chu you jian dao shu ju ku bing yi ge zhong fang shi suo yin : use Email::Store 'dbi:SQLite:mail.db'; Email::Store-setup; Email::Store::Mail-store($rfc2822); jin jie zhe ... my ($name) = Email::Store::Name-search( name = "Simon Cozens" ) @mails_from_simon = $name-addressings( role = "From" )-mails; ta ke yi yong lai gou jian lei si Mariachi de you jian lie biao gui dang gong ju , huo zhe lei si Mail::Miner de shu ju wa jue 。 ta reng ran zai chu bu de kai fa jie duan , bing zai zeng qiang mo kuai de kuo zhan xing fang mian shi yong le yi xie xin de si xiang 。 zai wo men shi yong Email::Store xie chu di yi ge you jian gui dang he sou suo gong ju de shi hou , wo hui zai ci gei da jia zuo xiang xi jie shao de 。 zhe ye shi wei le perl.org de xin de Perl you jian lie biao chu li jie kou er zhun bei zuo de gong zuo 。 xiao jie wo men yi jing kan guo le CPAN shang de ji ge zhu yao de you jian chu li mo kuai , dang ran huan you geng duo 。 hen ming xian de , wo zhe shi pian tan na xie zi ji xie de mo kuai 。 te ding de Perl dian zi you jian xiang mu de mo kuai ze shi yong Email::* de ming zi kong jian 。 wo men te bie she ji le zhe xie jian jie 、 gao xiao de mo kuai , er ta men bing bu zong shi lao shi de Mail::* mo kuai de you liang ti huan fang an , te bie xiang Mail::Box zhi lei 。 dao ci , wo xi wang ge wei tong guo dui ben wen de yue du , le jie he ren shi geng duo de you jian chu li gong ju mo kuai , bing zai zhi hou shi yong Perl lai chu li you jian shi , xiong zhong you qiu he 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
可爱小魔女
夏日小桃红
琦吖囡半熟乖巧清新写真
天使的微笑
痞子的甘南日记
疑是银河落九天
雪域坝上四——纯美色
冬日恋歌——西城杨柳弄轻柔
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有