From wanliyou at gmail.com Thu Aug 3 23:56:00 2006 From: wanliyou at gmail.com (=?GB2312?B?hWSEXoVk?=) Date: Fri, 4 Aug 2006 14:56:00 +0800 Subject: [PerlChina] =?gb2312?b?TFdQOjpVc2VyQWdlbnS1xMq508POyszi?= Message-ID: <41143d8f0608032355r10c5dc3bp107ce4dc55d76af5@mail.gmail.com> 本想截取某网站页面的数据,但总是不行 后想到可能要设proxy,于是看UserAgent的文档,发现$ua->proxy可以设置地址,但ID,怕ssword验证的方法是什么呢? 另外:$ua->credentials( $netloc, $realm, $uname, $pass );具体怎么用呢? -- --==Best Regards From WanLi==-- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060804/d641b93e/attachment.html From panjianfeng1979 at gmail.com Fri Aug 4 00:44:58 2006 From: panjianfeng1979 at gmail.com (=?GB2312?B?xcu9qLfm?=) Date: Fri, 4 Aug 2006 15:44:58 +0800 Subject: [PerlChina] =?gb2312?b?x+vOysjnus7Ns7zG19a3+7Su1tDEs7j2zPW8/rP2?= =?gb2312?b?z9a1xLTOyv0=?= Message-ID: <4bb3b0bc0608040044r15aaa2a1l86b0f33498e969f@mail.gmail.com> 比如:/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3] 中"="出现的次数。 谢谢! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060804/b56f9556/attachment.html From fayland at gmail.com Fri Aug 4 00:53:05 2006 From: fayland at gmail.com (fayland) Date: Fri, 04 Aug 2006 07:53:05 +0000 Subject: [PerlChina] =?gb2312?b?x+vOysjnus7Ns7zG19a3+7Su1tDEs7j2zPW8/rP2?= =?gb2312?b?z9a1xLTOyv0=?= In-Reply-To: <4bb3b0bc0608040044r15aaa2a1l86b0f33498e969f@mail.gmail.com> References: <4bb3b0bc0608040044r15aaa2a1l86b0f33498e969f@mail.gmail.com> Message-ID: <44D2FCE1.6080809@gmail.com> 潘建锋 wrote: > 比如:/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3] > 中"="出现的次数。 > 谢谢! my $a = '/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3]'; my $i; $i++ while ($a =~ /=/g); print $i; > ------------------------------------------------------------------------ > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm -- Fayland Lam // http://www.fayland.org/ From panjianfeng1979 at gmail.com Fri Aug 4 00:57:01 2006 From: panjianfeng1979 at gmail.com (=?GB2312?B?xcu9qLfm?=) Date: Fri, 4 Aug 2006 15:57:01 +0800 Subject: [PerlChina] =?gb2312?b?x+vOysjnus7Ns7zG19a3+7Su1tDEs7j2zPW8/rP2?= =?gb2312?b?z9a1xLTOyv0=?= In-Reply-To: <44D2FCE1.6080809@gmail.com> References: <4bb3b0bc0608040044r15aaa2a1l86b0f33498e969f@mail.gmail.com> <44D2FCE1.6080809@gmail.com> Message-ID: <4bb3b0bc0608040057l3b400438h3155c66ffa1c4d71@mail.gmail.com> 谢谢你了,没有专门的函数吗? 2006/8/4, fayland : > > 潘建锋 wrote: > > 比如:/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3] > > 中"="出现的次数。 > > 谢谢! > > my $a = '/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3]'; > > my $i; > $i++ while ($a =~ /=/g); > > print $i; > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > -- > Fayland Lam // http://www.fayland.org/ > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060804/e7ed0a79/attachment.html From panjianfeng1979 at gmail.com Fri Aug 4 02:07:26 2006 From: panjianfeng1979 at gmail.com (=?GB2312?B?xcu9qLfm?=) Date: Fri, 4 Aug 2006 17:07:26 +0800 Subject: [PerlChina] =?gb2312?b?x+u9zNK7uPbJosHQse21xMq508M=?= Message-ID: <4bb3b0bc0608040207u47c1f855md814375105279938@mail.gmail.com> my %levelMap = ( 'PS_INDETERMINATE' => 9, 'PS_CRITICAL' => 1, 'PS_MAJOR' => 2, 'PS_MINOR' => 3, 'PS_WARNING' => 4 ); $1 = 'PS_MINOR'; 但是下面的语句老是报错 print $levelMap{$1}; 提示Use of uninitialized value in print .... 请问是怎么回事?谢谢! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060804/4b02a234/attachment.html From fayland at gmail.com Fri Aug 4 02:12:31 2006 From: fayland at gmail.com (fayland) Date: Fri, 04 Aug 2006 09:12:31 +0000 Subject: [PerlChina] =?gb2312?b?x+u9zNK7uPbJosHQse21xMq508M=?= In-Reply-To: <4bb3b0bc0608040207u47c1f855md814375105279938@mail.gmail.com> References: <4bb3b0bc0608040207u47c1f855md814375105279938@mail.gmail.com> Message-ID: <44D30F7F.40900@gmail.com> 潘建锋 wrote: > my %levelMap = ( > 'PS_INDETERMINATE' => 9, > 'PS_CRITICAL' => 1, > 'PS_MAJOR' => 2, > 'PS_MINOR' => 3, > 'PS_WARNING' => 4 > ); > $1 = 'PS_MINOR'; > 但是下面的语句老是报错 > print $levelMap{$1}; > 提示Use of uninitialized value in print .... > 请问是怎么回事?谢谢! $a = 'PS_MINOR'; print $levelMap{$a}; $1 是给 Regex 用的。好象是只读的。 > ------------------------------------------------------------------------ > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm -- Fayland Lam // http://www.fayland.org/ From panjianfeng1979 at gmail.com Fri Aug 4 02:15:03 2006 From: panjianfeng1979 at gmail.com (=?GB2312?B?xcu9qLfm?=) Date: Fri, 4 Aug 2006 17:15:03 +0800 Subject: [PerlChina] =?gb2312?b?x+u9zNK7uPbJosHQse21xMq508M=?= In-Reply-To: <44D30F7F.40900@gmail.com> References: <4bb3b0bc0608040207u47c1f855md814375105279938@mail.gmail.com> <44D30F7F.40900@gmail.com> Message-ID: <4bb3b0bc0608040215h4849ef0evad103d755ac81fd9@mail.gmail.com> 搞定了,是一个低级错误,把%map的声明写到了子程序调用的下面 ,谢谢了。 2006/8/4, fayland : > > 潘建锋 wrote: > > my %levelMap = ( > > 'PS_INDETERMINATE' => 9, > > 'PS_CRITICAL' => 1, > > 'PS_MAJOR' => 2, > > 'PS_MINOR' => 3, > > 'PS_WARNING' => 4 > > ); > > $1 = 'PS_MINOR'; > > 但是下面的语句老是报错 > > print $levelMap{$1}; > > 提示Use of uninitialized value in print .... > > 请问是怎么回事?谢谢! > > $a = 'PS_MINOR'; > > print $levelMap{$a}; > > $1 是给 Regex 用的。好象是只读的。 > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > -- > Fayland Lam // http://www.fayland.org/ > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060804/d4926059/attachment.html From jeffhua at aol.com Fri Aug 4 02:16:43 2006 From: jeffhua at aol.com (jeffhua at aol.com) Date: Fri, 04 Aug 2006 05:16:43 -0400 Subject: [PerlChina] =?utf-8?b?6K+35pWZ5LiA5Liq5pWj5YiX6KGo55qE5L2/55So?= =?utf-8?q?_?= In-Reply-To: <4bb3b0bc0608040207u47c1f855md814375105279938@mail.gmail.com> References: <4bb3b0bc0608040207u47c1f855md814375105279938@mail.gmail.com> Message-ID: <8C885BDD64E9BA8-D90-8D@FWM-R09.sysops.aol.com> When you run the script with 'use warnings' you could get the errors: Modification of a read-only value attempted $1 is a special variable in Perl,you couldn't modify it using the statement of '$1 = ...'. -----Original Message----- From: panjianfeng1979 at gmail.com To: china-pm at pm.org Sent: Fri, 4 Aug 2006 5:07 PM Subject: [PerlChina] 请教一个散列表的使用 my %levelMap = (     'PS_INDETERMINATE' => 9,     'PS_CRITICAL'      => 1,     'PS_MAJOR'         => 2,     'PS_MINOR'         => 3,     'PS_WARNING'       => 4 ); $1 = 'PS_MINOR'; 但是下面的语句老是报错 print $levelMap{$1}; 提示Use of uninitialized value in print .... 请问是怎么回事?谢谢! _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm ________________________________________________________________________ Check out AOL.com today. Breaking news, video search, pictures, email and IM. All on demand. Always Free. From panjianfeng1979 at gmail.com Fri Aug 4 02:20:01 2006 From: panjianfeng1979 at gmail.com (=?GB2312?B?xcu9qLfm?=) Date: Fri, 4 Aug 2006 17:20:01 +0800 Subject: [PerlChina] =?gb2312?b?x+u9zNK7uPbJosHQse21xMq508M=?= In-Reply-To: <8C885BDD64E9BA8-D90-8D@FWM-R09.sysops.aol.com> References: <4bb3b0bc0608040207u47c1f855md814375105279938@mail.gmail.com> <8C885BDD64E9BA8-D90-8D@FWM-R09.sysops.aol.com> Message-ID: <4bb3b0bc0608040220j9303bcej51fdbbfc7b3050f8@mail.gmail.com> 好像没有用,并且我已经用了 use strict; 还需要用 use warnings 吗? 2006/8/4, jeffhua at aol.com : > > When you run the script with 'use warnings' you could get the errors: > > Modification of a read-only value attempted > > $1 is a special variable in Perl,you couldn't modify it using the > statement of '$1 = ...'. > > > > > -----Original Message----- > From: panjianfeng1979 at gmail.com > To: china-pm at pm.org > Sent: Fri, 4 Aug 2006 5:07 PM > Subject: [PerlChina] 请教一个散列表的使用 > > my %levelMap = ( > 'PS_INDETERMINATE' => 9, > 'PS_CRITICAL' => 1, > 'PS_MAJOR' => 2, > 'PS_MINOR' => 3, > 'PS_WARNING' => 4 > ); > $1 = 'PS_MINOR'; > 但是下面的语句老是报错 > print $levelMap{$1}; > 提示Use of uninitialized value in print .... > 请问是怎么回事?谢谢! > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > > ________________________________________________________________________ > Check out AOL.com today. Breaking news, video search, pictures, email > and IM. All on demand. Always Free. > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060804/6f583fb1/attachment.html From havel.zhang at gmail.com Fri Aug 4 04:12:01 2006 From: havel.zhang at gmail.com (Havel Zhang) Date: Fri, 4 Aug 2006 19:12:01 +0800 Subject: [PerlChina] =?gb2312?b?x+vOysjnus7Ns7zG19a3+7Su1tDEs7j2zPW8/rP2?= =?gb2312?b?z9a1xLTOyv0=?= In-Reply-To: <4bb3b0bc0608040057l3b400438h3155c66ffa1c4d71@mail.gmail.com> References: <4bb3b0bc0608040044r15aaa2a1l86b0f33498e969f@mail.gmail.com> <44D2FCE1.6080809@gmail.com> <4bb3b0bc0608040057l3b400438h3155c66ffa1c4d71@mail.gmail.com> Message-ID: 呵呵,还有如下的方法:) my $a = '/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3]'; my $i; $i = split /=/,$a; print $i-1; On 8/4/06, 潘建锋 wrote: > > 谢谢你了,没有专门的函数吗? > > 2006/8/4, fayland : > > > 潘建锋 wrote: > > > 比如:/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3] > > > 中"="出现的次数。 > > > 谢谢! > > > > my $a = '/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3]'; > > > > my $i; > > $i++ while ($a =~ /=/g); > > > > print $i; > > > > > > > ------------------------------------------------------------------------ > > > > > > _______________________________________________ > > > China-pm mailing list > > > China-pm at pm.org > > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > > -- > > Fayland Lam // http://www.fayland.org/ > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > -- 真理使你自由 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060804/8a6dfe0e/attachment.html From havel.zhang at gmail.com Fri Aug 4 04:25:31 2006 From: havel.zhang at gmail.com (Havel Zhang) Date: Fri, 4 Aug 2006 19:25:31 +0800 Subject: [PerlChina] =?gb2312?b?udjT2nNwbGl0uq/K/bXE0KHOyszi?= Message-ID: hi everyone: 有一个小问题请教各位弟兄,是关于split函数的。 我要把一个字串分成两个字段,以'|'为分隔符,程序应该是: @a = split /\|/','item_code|store_code'; print join("\n", at a); 出来的结果是: item_code store_code 而我将程序改为: @a = split "|",'item_code|store_code'; #把"|"改成"\|" 也一样 print join("\n", at a); 出来的结果是: i t e m - c o d e | s t o r e - c o d e 不知有哪位弟兄能指点一下,split中//和""的不同? -- 真理使你自由 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060804/2d451868/attachment.html From qian.jinmo at gmail.com Fri Aug 4 23:48:34 2006 From: qian.jinmo at gmail.com (jinmo qian) Date: Sat, 5 Aug 2006 15:48:34 +0900 Subject: [PerlChina] =?gb2312?b?udjT2nNwbGl0uq/K/bXE0KHOyszi?= In-Reply-To: References: Message-ID: <29edbdf90608042348p23b881f1o95dcf65131b76247@mail.gmail.com> split的第一个参数只能是正则表达式。如果是字符串的话,会给转成一个正则表达式。比如说 my @a = split 'e|c','item_code|store_code'; print join("\n", at a); 的输出结果就是 it m_ od |stor _ od 用"\|"的话,转化后的正则表达式还是/|/,因为\在双引号里已经用来转意|了,就不会放在正则表达式里了。这种情况下要用单引号。 On 8/4/06, Havel Zhang wrote: > > hi everyone: > > 有一个小问题请教各位弟兄,是关于split函数的。 > 我要把一个字串分成两个字段,以'|'为分隔符,程序应该是: > @a = split /\|/','item_code|store_code'; > print join("\n", at a); > > 出来的结果是: > item_code > store_code > 而我将程序改为: > @a = split "|",'item_code|store_code'; #把"|"改成"\|" 也一样 > print join("\n", at a); > 出来的结果是: > i > t > e > m > - > c > o > d > e > | > s > t > o > r > e > - > c > o > d > e > > 不知有哪位弟兄能指点一下,split中//和""的不同? > > -- > 真理使你自由 > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > From shijialee at gmail.com Sun Aug 6 20:40:38 2006 From: shijialee at gmail.com (Qiang (James) Li) Date: Sun, 6 Aug 2006 23:40:38 -0400 Subject: [PerlChina] =?gb2312?b?TFdQOjpVc2VyQWdlbnS1xMq508POyszi?= In-Reply-To: <41143d8f0608032355r10c5dc3bp107ce4dc55d76af5@mail.gmail.com> References: <41143d8f0608032355r10c5dc3bp107ce4dc55d76af5@mail.gmail.com> Message-ID: <4ab5ddef0608062040i4dca9958g4614f63e83aa1ae1@mail.gmail.com> On 8/4/06, �d�^�d wrote: > > ������ij�վҳ���������� > > ��������proxy������UserAgent��ĵ������$ua->proxy�����������ID���ssword�֤�ķ����ʲô��� short answer: $ua->proxy(['http', 'ftp'] => 'http://username:password at proxy.myorg.com'); long answer, read: perldoc lwpcook > ����$ua->credentials( $netloc, $realm, $uname, $pass );���ô���� read: http://www.perlchina.org/archive/archive.php?action=archive&page=15 or lwpcook sorry, no chinese here and i am on 56k dial-up ;-0 Qiang From shijialee at gmail.com Sun Aug 6 20:45:31 2006 From: shijialee at gmail.com (Qiang (James) Li) Date: Sun, 6 Aug 2006 23:45:31 -0400 Subject: [PerlChina] =?gb2312?b?x+u9zNK7uPbJosHQse21xMq508M=?= In-Reply-To: <4bb3b0bc0608040220j9303bcej51fdbbfc7b3050f8@mail.gmail.com> References: <4bb3b0bc0608040207u47c1f855md814375105279938@mail.gmail.com> <8C885BDD64E9BA8-D90-8D@FWM-R09.sysops.aol.com> <4bb3b0bc0608040220j9303bcej51fdbbfc7b3050f8@mail.gmail.com> Message-ID: <4ab5ddef0608062045w1d3808b2s584942e869caf0f3@mail.gmail.com> On 8/4/06, 潘建锋 wrote: > 好像没有用,并且我已经用了 > use strict; > 还需要用 > use warnings > 吗? yes. You should. and every Perl programmers should. Qiang > 2006/8/4, jeffhua at aol.com : > > When you run the script with 'use warnings' you could get the errors: > > > > Modification of a read-only value attempted > > > > $1 is a special variable in Perl,you couldn't modify it using the > > statement of '$1 = ...'. > > > > > > > > > > -----Original Message----- > > From: panjianfeng1979 at gmail.com > > To: china-pm at pm.org > > Sent: Fri, 4 Aug 2006 5:07 PM > > Subject: [PerlChina] 请教一个散列表的使用 > > > > my %levelMap = ( > > 'PS_INDETERMINATE' => 9, > > 'PS_CRITICAL' => 1, > > 'PS_MAJOR' => 2, > > 'PS_MINOR' => 3, > > 'PS_WARNING' => 4 > > ); > > $1 = 'PS_MINOR'; > > 但是下面的语句老是报错 > > print $levelMap{$1}; > > 提示Use of uninitialized value in print .... > > 请问是怎么回事?谢谢! > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > ________________________________________________________________________ > > Check out AOL.com today. Breaking news, video search, pictures, email > > and IM. All on demand. Always Free. > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > From havel.zhang at gmail.com Sun Aug 6 20:58:12 2006 From: havel.zhang at gmail.com (Havel Zhang) Date: Mon, 7 Aug 2006 11:58:12 +0800 Subject: [PerlChina] =?gb2312?b?udjT2nNwbGl0uq/K/bXE0KHOyszi?= In-Reply-To: <29edbdf90608042348p23b881f1o95dcf65131b76247@mail.gmail.com> References: <29edbdf90608042348p23b881f1o95dcf65131b76247@mail.gmail.com> Message-ID: 谢谢,Perl实在是太灵活了,也很有意思。 On 8/5/06, jinmo qian wrote: > > split的第一个参数只能是正则表达式。如果是字符串的话,会给转成一个正则表达式。比如说 > > my @a = split 'e|c','item_code|store_code'; > print join("\n", at a); > > 的输出结果就是 > > it > m_ > od > |stor > _ > od > > 用"\|"的话,转化后的正则表达式还是/|/,因为\在双引号里已经用来转意|了,就不会放在正则表达式里了。这种情况下要用单引号。 > > On 8/4/06, Havel Zhang wrote: > > > > hi everyone: > > > > 有一个小问题请教各位弟兄,是关于split函数的。 > > 我要把一个字串分成两个字段,以'|'为分隔符,程序应该是: > > @a = split /\|/','item_code|store_code'; > > print join("\n", at a); > > > > 出来的结果是: > > item_code > > store_code > > 而我将程序改为: > > @a = split "|",'item_code|store_code'; #把"|"改成"\|" 也一样 > > print join("\n", at a); > > 出来的结果是: > > i > > t > > e > > m > > - > > c > > o > > d > > e > > | > > s > > t > > o > > r > > e > > - > > c > > o > > d > > e > > > > 不知有哪位弟兄能指点一下,split中//和""的不同? > > > > -- > > 真理使你自由 > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm -- 真理使你自由 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060807/1a5c825d/attachment.html From wanliyou at gmail.com Sun Aug 6 21:51:14 2006 From: wanliyou at gmail.com (=?GB2312?B?hWSEXoVk?=) Date: Mon, 7 Aug 2006 12:51:14 +0800 Subject: [PerlChina] =?gb2312?b?TFdQOjpVc2VyQWdlbnS1xMq508POyszi?= In-Reply-To: <4ab5ddef0608062040i4dca9958g4614f63e83aa1ae1@mail.gmail.com> References: <41143d8f0608032355r10c5dc3bp107ce4dc55d76af5@mail.gmail.com> <4ab5ddef0608062040i4dca9958g4614f63e83aa1ae1@mail.gmail.com> Message-ID: <41143d8f0608062151m3707ef01g8f0b3c316daacc38@mail.gmail.com> English DOC is enough. Thanks a lot! On 8/7/06, Qiang (James) Li wrote: > > On 8/4/06, �d�^�d wrote: > > > > ������ij�վҳ���������� > > > > ��������proxy������UserAgent��ĵ������$ua->proxy�����������ID���ssword�֤�ķ����ʲô��� > > short answer: > $ua->proxy(['http', 'ftp'] => ' > http://username:password at proxy.myorg.com'); > long answer, read: perldoc lwpcook > > > ����$ua->credentials( $netloc, $realm, $uname, $pass );���ô���� > > read: > http://www.perlchina.org/archive/archive.php?action=archive&page=15 > or lwpcook > > sorry, no chinese here and i am on 56k dial-up ;-0 > > Qiang > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > -- --==Best Regards From WanLi==-- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060807/737e2cdd/attachment.html From panjianfeng1979 at gmail.com Sun Aug 6 22:45:35 2006 From: panjianfeng1979 at gmail.com (=?GB2312?B?xcu9qLfm?=) Date: Mon, 7 Aug 2006 13:45:35 +0800 Subject: [PerlChina] =?gb2312?b?x+u9zNK7uPbJosHQse21xMq508M=?= In-Reply-To: <4ab5ddef0608062045w1d3808b2s584942e869caf0f3@mail.gmail.com> References: <4bb3b0bc0608040207u47c1f855md814375105279938@mail.gmail.com> <8C885BDD64E9BA8-D90-8D@FWM-R09.sysops.aol.com> <4bb3b0bc0608040220j9303bcej51fdbbfc7b3050f8@mail.gmail.com> <4ab5ddef0608062045w1d3808b2s584942e869caf0f3@mail.gmail.com> Message-ID: <4bb3b0bc0608062245s1dc88c4eue91753de737dd03b@mail.gmail.com> 谢谢你的指点。以后我会加上的。:-) 2006/8/7, Qiang (James) Li : > > On 8/4/06, 潘建锋 wrote: > > 好像没有用,并且我已经用了 > > use strict; > > 还需要用 > > use warnings > > 吗? > > yes. You should. and every Perl programmers should. > > Qiang > > > > 2006/8/4, jeffhua at aol.com : > > > When you run the script with 'use warnings' you could get the errors: > > > > > > Modification of a read-only value attempted > > > > > > $1 is a special variable in Perl,you couldn't modify it using the > > > statement of '$1 = ...'. > > > > > > > > > > > > > > > -----Original Message----- > > > From: panjianfeng1979 at gmail.com > > > To: china-pm at pm.org > > > Sent: Fri, 4 Aug 2006 5:07 PM > > > Subject: [PerlChina] 请教一个散列表的使用 > > > > > > my %levelMap = ( > > > 'PS_INDETERMINATE' => 9, > > > 'PS_CRITICAL' => 1, > > > 'PS_MAJOR' => 2, > > > 'PS_MINOR' => 3, > > > 'PS_WARNING' => 4 > > > ); > > > $1 = 'PS_MINOR'; > > > 但是下面的语句老是报错 > > > print $levelMap{$1}; > > > 提示Use of uninitialized value in print .... > > > 请问是怎么回事?谢谢! > > > > > > _______________________________________________ > > > China-pm mailing list > > > China-pm at pm.org > > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > > > > ________________________________________________________________________ > > > Check out AOL.com today. Breaking news, video search, pictures, email > > > and IM. All on demand. Always Free. > > > _______________________________________________ > > > China-pm mailing list > > > China-pm at pm.org > > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060807/d21abadd/attachment-0001.html From wanliyou at gmail.com Mon Aug 7 00:25:56 2006 From: wanliyou at gmail.com (=?GB2312?B?hWSEXoVk?=) Date: Mon, 7 Aug 2006 15:25:56 +0800 Subject: [PerlChina] =?gb2312?b?TFdQOjpVc2VyQWdlbnS1xMq508POyszi?= In-Reply-To: <41143d8f0608062151m3707ef01g8f0b3c316daacc38@mail.gmail.com> References: <41143d8f0608032355r10c5dc3bp107ce4dc55d76af5@mail.gmail.com> <4ab5ddef0608062040i4dca9958g4614f63e83aa1ae1@mail.gmail.com> <41143d8f0608062151m3707ef01g8f0b3c316daacc38@mail.gmail.com> Message-ID: <41143d8f0608070025j7bc07ac8x7f205cdf6feb35ae@mail.gmail.com> $ua->proxy(['http', 'ftp'] => 'http://username:password at proxy.myorg.com' ); ������Ӧ���в�ͨ�ģ�����Ӧ���ã� credentials($hostport,$realm,$name,$pass) ���ĺ����$realm�ô˵�� "$realm�realm name�remote-Server��serҪ��֤������������ô���� On 8/7/06, �d�^�d wrote: > > English DOC is enough. > Thanks a lot! > > > On 8/7/06, Qiang (James) Li wrote: > > > On 8/4/06, �d�^�d wrote: > > > > ������ij�վҳ���������� > > > > ��������proxy������UserAgent��ĵ������$ua->proxy�����������ID���ssword�֤�ķ����ʲô��� > > short answer: > $ua->proxy(['http', 'ftp'] => 'http://username:password at proxy.myorg.com' > ); > long answer, read: perldoc lwpcook > > > ����$ua->credentials( $netloc, $realm, $uname, $pass );���ô���� > > read: > http://www.perlchina.org/archive/archive.php?action=archive&page=15 > or lwpcook > > sorry, no chinese here and i am on 56k dial-up ;-0 > > Qiang > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > > > > -- > --==Best Regards From WanLi==-- > -- --==Best Regards From WanLi==-- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060807/8f296dd0/attachment.html From wanliyou at gmail.com Mon Aug 7 02:07:27 2006 From: wanliyou at gmail.com (=?GB2312?B?hWSEXoVk?=) Date: Mon, 7 Aug 2006 17:07:27 +0800 Subject: [PerlChina] =?gb2312?b?TFdQOjpVc2VyQWdlbnS1xMq508POyszi?= In-Reply-To: <41143d8f0608070025j7bc07ac8x7f205cdf6feb35ae@mail.gmail.com> References: <41143d8f0608032355r10c5dc3bp107ce4dc55d76af5@mail.gmail.com> <4ab5ddef0608062040i4dca9958g4614f63e83aa1ae1@mail.gmail.com> <41143d8f0608062151m3707ef01g8f0b3c316daacc38@mail.gmail.com> <41143d8f0608070025j7bc07ac8x7f205cdf6feb35ae@mail.gmail.com> Message-ID: <41143d8f0608070207k32912bdapddf2c7196975da3b@mail.gmail.com> Some proxies also require that you send it a username/password in order to let requests through. You should be able to add the required header, with something like this: use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->proxy(['http', 'ftp'] => 'http://username:password at proxy.myorg.com'); $req = HTTP::Request->new('GET',"http://www.perl.com"); $res = $ua->request($req); print $res->decoded_content if $res->is_success; Replace C, C and C with something suitable for your site. �ȻҲ��ôд�ģ���������ͨ��Can't locate object method "decoded_content" via package "HTTP::Headers" at (eval 14) line 1. On 8/7/06, �d�^�d wrote: > > $ua->proxy(['http', 'ftp'] => 'http://username:password at proxy.myorg.com' > ); > > ������Ӧ���в�ͨ�ģ�����Ӧ���ã� > > credentials($hostport,$realm,$name,$pass) > > ���ĺ����$realm�ô˵�� > > "$realm�realm name�remote-Server��serҪ��֤������ �������ô���� > > > On 8/7/06, �d�^�d wrote: > > > > English DOC is enough. > > Thanks a lot! > > > > > > On 8/7/06, Qiang (James) Li < shijialee at gmail.com> wrote: > > > > > On 8/4/06, �d�^�d < wanliyou at gmail.com> wrote: > > > > > > ������ij�վҳ���������� > > > > > > ��������proxy������UserAgent��ĵ������$ua->proxy�����������ID���ssword�֤�ķ����ʲô��� > > > > short answer: > > $ua->proxy(['http', 'ftp'] => 'http://username:password at proxy.myorg.com' > > ); > > long answer, read: perldoc lwpcook > > > > > ����$ua->credentials( $netloc, $realm, $uname, $pass );���ô���� > > > > read: > > http://www.perlchina.org/archive/archive.php?action=archive&page=15 > > or lwpcook > > > > sorry, no chinese here and i am on 56k dial-up ;-0 > > > > Qiang > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > > > > -- > > --==Best Regards From WanLi==-- > > > > > > -- > --==Best Regards From WanLi==-- > -- --==Best Regards From WanLi==-- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060807/08e132b7/attachment.html From jeffhua at aol.com Mon Aug 7 23:10:56 2006 From: jeffhua at aol.com (jeffhua at aol.com) Date: Tue, 08 Aug 2006 02:10:56 -0400 Subject: [PerlChina] =?utf-8?b?5pyJTWFzb27nlKjmiLflkJfvvJ8g?= Message-ID: <8C888C88B9EE4E7-DCC-1ADB@FWM-M06.sysops.aol.com> Hello, 这里有Mason开发者吗?大家交流下,:-) 我了解这个不多,据说是很好的HTML Template. ---- Jeff Peng JeffHua at aol.com yonghua_peng at yahoo.com.cn ________________________________________________________________________ Check out AOL.com today. Breaking news, video search, pictures, email and IM. All on demand. Always Free. From jameswork66 at gmail.com Wed Aug 9 11:56:15 2006 From: jameswork66 at gmail.com (James Zheng) Date: Thu, 10 Aug 2006 02:56:15 +0800 Subject: [PerlChina] =?utf-8?b?5pyJTWFzb27nlKjmiLflkJfvvJ8=?= References: <8C888C88B9EE4E7-DCC-1ADB@FWM-M06.sysops.aol.com> Message-ID: <027d01c6bbe5$7fef1e40$0801a8c0@james> 得看自己的看法了, 我们天天用, 项目做大了, 人多了就麻烦了. ----- Original Message ----- From: To: Sent: Tuesday, August 08, 2006 2:10 PM Subject: [PerlChina] 有Mason用户吗? > Hello, > 这里有Mason开发者吗?大家交流下,:-) > 我了解这个不多,据说是很好的HTML Template. > > > ---- > Jeff Peng > JeffHua at aol.com > yonghua_peng at yahoo.com.cn > ________________________________________________________________________ > Check out AOL.com today. Breaking news, video search, pictures, email > and IM. All on demand. Always Free. > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm From formalin14 at gmail.com Wed Aug 9 19:05:03 2006 From: formalin14 at gmail.com (Achilles Achilles) Date: Thu, 10 Aug 2006 10:05:03 +0800 Subject: [PerlChina] =?gb2312?b?09BNYXNvbtPDu6fC8KO/?= In-Reply-To: <027d01c6bbe5$7fef1e40$0801a8c0@james> References: <8C888C88B9EE4E7-DCC-1ADB@FWM-M06.sysops.aol.com> <027d01c6bbe5$7fef1e40$0801a8c0@james> Message-ID: <4a6c0ba80608091905m2a92c221w88e4f0518c30a65@mail.gmail.com> 我觉得还是用不那么灵活的模板好点,模板应该是给美工改的。里面的标记越少越好。有个替换和循环功能就行了。 On 8/10/06, James Zheng wrote: > > 得看自己的看法了, 我们天天用, 项目做大了, 人多了就麻烦了. > > > ----- Original Message ----- > From: > To: > Sent: Tuesday, August 08, 2006 2:10 PM > Subject: [PerlChina] 有Mason用户吗? > > > > Hello, > > 这里有Mason开发者吗?大家交流下,:-) > > 我了解这个不多,据说是很好的HTML Template. > > > > > > ---- > > Jeff Peng > > JeffHua at aol.com > > yonghua_peng at yahoo.com.cn > > ________________________________________________________________________ > > Check out AOL.com today. Breaking news, video search, pictures, email > > and IM. All on demand. Always Free. > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm -- --------------------------- Achilles Xu http://www.lazycode.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060810/474f2579/attachment.html From jeffhua at aol.com Wed Aug 9 21:03:53 2006 From: jeffhua at aol.com (jeffhua at aol.com) Date: Thu, 10 Aug 2006 00:03:53 -0400 Subject: [PerlChina] =?utf-8?b?5pyJTWFzb27nlKjmiLflkJfvvJ8g?= In-Reply-To: <4a6c0ba80608091905m2a92c221w88e4f0518c30a65@mail.gmail.com> References: <8C888C88B9EE4E7-DCC-1ADB@FWM-M06.sysops.aol.com> <027d01c6bbe5$7fef1e40$0801a8c0@james> <4a6c0ba80608091905m2a92c221w88e4f0518c30a65@mail.gmail.com> Message-ID: <8C88A4920C68AEF-A68-EF40@FWM-M11.sysops.aol.com> 简单测试了下,感觉Mason很慢。 modperl是很快的,可能Mason花太多时间解析它自己的命令。 不用template也不方便,在perl里print大量html代码是件痛苦的事。 -----Original Message----- From: formalin14 at gmail.com To: china-pm at pm.org Sent: Thu, 10 Aug 2006 10:05 AM Subject: Re: [PerlChina] 有Mason用户吗? 我觉得还是用不那么灵活的模板好点,模板应该是给美工改的。里面的标记越少越好。有个替换和循环功能就行了。 On 8/10/06, James Zheng wrote: 得看自己的看法了, 我们天天用, 项 目做大了, 人多了就麻烦了. ----- Original Message ----- From: < jeffhua at aol.com> To: Sent: Tuesday, August 08, 2006 2:10 PM Subject: [PerlChina] 有Mason用户吗? > Hello, > 这里有Mason开发者吗?大家交流下,:-) > 我了解这个不多,据说是很好的HTML Template. > > > ---- > Jeff Peng > JeffHua at aol.com > yonghua_peng at yahoo.com.cn > ________________________________________________________________________ > Check out AOL.com today. Breaking news, video search, pictures, email > and IM. All on demand. Always Free. > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm -- --------------------------- Achilles Xu http://www.lazycode.org _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm ________________________________________________________________________ Check out AOL.com today. Breaking news, video search, pictures, email and IM. All on demand. Always Free. From jameswork66 at gmail.com Wed Aug 9 23:13:17 2006 From: jameswork66 at gmail.com (James Zheng) Date: Thu, 10 Aug 2006 14:13:17 +0800 Subject: [PerlChina] =?gb2312?b?09BNYXNvbtPDu6fC8KO/?= References: <8C888C88B9EE4E7-DCC-1ADB@FWM-M06.sysops.aol.com><027d01c6bbe5$7fef1e40$0801a8c0@james> <4a6c0ba80608091905m2a92c221w88e4f0518c30a65@mail.gmail.com> Message-ID: <03f101c6bc44$182a2110$0801a8c0@james> 呵呵, 同意, 我们现在是catalyst和 mason两个系统都在用 ----- Original Message ----- From: Achilles Achilles To: china-pm at pm.org Sent: Thursday, August 10, 2006 10:05 AM Subject: Re: [PerlChina] 有Mason用户吗? 我觉得还是用不那么灵活的模板好点,模板应该是给美工改的。里面的标记越少越好。有个替换和循环功能就行了。 On 8/10/06, James Zheng wrote: 得看自己的看法了, 我们天天用, 项目做大了, 人多了就麻烦了. ----- Original Message ----- From: < jeffhua at aol.com> To: Sent: Tuesday, August 08, 2006 2:10 PM Subject: [PerlChina] 有Mason用户吗? > Hello, > 这里有Mason开发者吗?大家交流下,:-) > 我了解这个不多,据说是很好的HTML Template. > > > ---- > Jeff Peng > JeffHua at aol.com > yonghua_peng at yahoo.com.cn > ________________________________________________________________________ > Check out AOL.com today. Breaking news, video search, pictures, email > and IM. All on demand. Always Free. > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm -- --------------------------- Achilles Xu http://www.lazycode.org ------------------------------------------------------------------------------ _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060810/4f1ffda6/attachment.html From poorest at gmail.com Thu Aug 10 06:21:54 2006 From: poorest at gmail.com (poorest) Date: Thu, 10 Aug 2006 21:21:54 +0800 Subject: [PerlChina] =?gb2312?b?x+u9zNK7uPbJosHQse21xMq508M=?= In-Reply-To: <4ab5ddef0608062045w1d3808b2s584942e869caf0f3@mail.gmail.com> Message-ID: <005601c6bc7f$f5e6a600$0301a8c0@PoorestTP> I think to use warnings or not depends whether you are debugging yourself, or you deliver to your client. For some stupid clients, I guess it would be better to disable warnings in case of frightening. -----Original Message----- From: china-pm-bounces+poorest=gmail.com at pm.org [mailto:china-pm-bounces+poorest=gmail.com at pm.org] On Behalf Of Qiang (James) Li Sent: Monday, August 07, 2006 11:46 To: china-pm at pm.org Subject: Re: [PerlChina] 请教一个散列表的使用 On 8/4/06, 潘建锋 wrote: > 好像没有用,并且我已经用了 > use strict; > 还需要用 > use warnings > 吗? yes. You should. and every Perl programmers should. Qiang > 2006/8/4, jeffhua at aol.com : > > When you run the script with 'use warnings' you could get the errors: > > > > Modification of a read-only value attempted > > > > $1 is a special variable in Perl,you couldn't modify it using the > > statement of '$1 = ...'. > > > > > > > > > > -----Original Message----- > > From: panjianfeng1979 at gmail.com > > To: china-pm at pm.org > > Sent: Fri, 4 Aug 2006 5:07 PM > > Subject: [PerlChina] 请教一个散列表的使用 > > > > my %levelMap = ( > > 'PS_INDETERMINATE' => 9, > > 'PS_CRITICAL' => 1, > > 'PS_MAJOR' => 2, > > 'PS_MINOR' => 3, > > 'PS_WARNING' => 4 > > ); > > $1 = 'PS_MINOR'; > > 但是下面的语句老是报错 > > print $levelMap{$1}; > > 提示Use of uninitialized value in print .... > > 请问是怎么回事?谢谢! > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > ________________________________________________________________________ > > Check out AOL.com today. Breaking news, video search, pictures, email > > and IM. All on demand. Always Free. > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm From jeffhua at aol.com Thu Aug 10 06:45:11 2006 From: jeffhua at aol.com (jeffhua at aol.com) Date: Thu, 10 Aug 2006 09:45:11 -0400 Subject: [PerlChina] =?utf-8?b?6K+35pWZ5LiA5Liq5pWj5YiX6KGo55qE5L2/55So?= =?utf-8?q?_?= In-Reply-To: <005601c6bc7f$f5e6a600$0301a8c0@PoorestTP> Message-ID: <8C88A9A55FB5A8B-820-3139@FWM-M06.sysops.aol.com> Yes,至少在modperl下是如此。 通常产品上线后,后关闭use warnings;否则日志里会一堆报警。 -----Original Message----- From: poorest at gmail.com To: china-pm at pm.org Sent: Thu, 10 Aug 2006 9:21 PM Subject: Re: [PerlChina] 请教一个散列表的使用 I think to use warnings or not depends whether you are debugging yourself, or you deliver to your client. For some stupid clients, I guess it would be better to disable warnings in case of frightening. -----Original Message----- From: china-pm-bounces+poorest=gmail.com at pm.org [mailto:china-pm-bounces+poorest=gmail.com at pm.org] On Behalf Of Qiang (James) Li Sent: Monday, August 07, 2006 11:46 To: china-pm at pm.org Subject: Re: [PerlChina] 请教一个散列表的使用 On 8/4/06, 潘建锋 wrote: > 好像没有用,并且我已经用了 > use strict; > 还需要用 > use warnings > 吗? yes. You should. and every Perl programmers should. Qiang > 2006/8/4, jeffhua at aol.com : > > When you run the script with 'use warnings' you could get the errors: > > > > Modification of a read-only value attempted > > > > $1 is a special variable in Perl,you couldn't modify it using the > > statement of '$1 = ...'. > > > > > > > > > > -----Original Message----- > > From: panjianfeng1979 at gmail.com > > To: china-pm at pm.org > > Sent: Fri, 4 Aug 2006 5:07 PM > > Subject: [PerlChina] 请教一个散列表的使用 > > > > my %levelMap = ( > > 'PS_INDETERMINATE' => 9, > > 'PS_CRITICAL' => 1, > > 'PS_MAJOR' => 2, > > 'PS_MINOR' => 3, > > 'PS_WARNING' => 4 > > ); > > $1 = 'PS_MINOR'; > > 但是下面的语句老是报错 > > print $levelMap{$1}; > > 提示Use of uninitialized value in print .... > > 请问是怎么回事?谢谢! > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > ________________________________________________________________________ > > Check out AOL.com today. Breaking news, video search, pictures, email > > and IM. All on demand. Always Free. > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm ________________________________________________________________________ Check out AOL.com today. Breaking news, video search, pictures, email and IM. All on demand. Always Free. From shanleiguang at gmail.com Sun Aug 13 21:41:08 2006 From: shanleiguang at gmail.com (Shan Leiguang) Date: Mon, 14 Aug 2006 12:41:08 +0800 Subject: [PerlChina] =?gb2312?b?UE9FIGVYYW1wbGUgo60gYWxhcm1fZm9yd2FyZGVy?= Message-ID: alarm_collecters -> alarm_forwarder -> alarm_monitors ac_101_001... ac_101_002... 描述:一个告警监控程序的告警转发部分,有一组告警采集程序采集101系统的告警 然后写到log/101的目录下,alarm_forwarder在10001端口监听,并定期扫描log目录, 将日志内容放到队列中,有客户端连接时将队列的内容发送给客户端。 *file1:conf/ports_mapping.conf* #ALarm Ports Mapping Config 101 NMS-selfMonitor 10001 *file2:alarm_forwarder.pl* #!C:\Perl\bin\perl.exe #Forward alarms of virual NEs to NFM or self-Monitor client #By shanleiguang at he.chinamobile.com, 2006/08 # # Events #-------- # # +------<------+ # | | +---<----+ # load_config->create_queues-+->alarm_scanning->update_queues | | # (queues) | |->client_send->+ # | |->accept_success-+->client_error # +->start_listen-+ (client_wheels) # (listen_wheels)| # |->accept_failure # $_[HEAP] #---------- # $[HEAP]->{vnes}->{$vid}->{desc, port, queue, alarm_files, listen_wheel, client_wheels} # package virtualOMC; use strict; use warnings; use Socket; use IO::File; use IO::File::Multi; use Queue::Base; use POSIX qw/strftime/; use POE; use POE::Driver::SysRW; use POE::Filter::Stream; use POE::Wheel::ReadWrite; use POE::Wheel::SocketFactory; use constant PACKAGE_VERSION => '0.1'; use constant SELF_NAME => 'alarmForwarder'; use constant SELF_VERSION => '0.2'; use constant MAX_LENGTH => 10000; use constant SCANNING_TIMER => 20; use constant SENDING_TIMER => 30; #For debug use Data::Dumper; my $logdir = 'log'; my $confdir = 'conf'; my $alarmdir = 'alarm'; my $pmconfig = 'ports_mapping.conf'; my $logfile = (strftime "%Y%m%d", localtime).'.log'; my $output = new IO::File::Multi; POE::Session->create( inline_states => { _start => \&main_start, _stop => \&main_stop, alarm_scanning => \&alarm_scanning, update_queues => \&update_queues, start_listen => \&start_listen, accept_success => \&accept_success, accept_failure => \&accept_failure, client_send => \&client_send, client_error => \&client_error, }, ); POE::Kernel->run(); exit; #Get timestamp sub ts { return strftime "%H:%M:%S", localtime; } #'_start' event sub main_start { $output->open('>-'); $output->open(">> $logdir/$logfile"); $output->autoflush(1); $output->print("\n".('=' x 60)."\n"); $output->print(SELF_NAME.SELF_VERSION.' of '.__PACKAGE__.PACKAGE_VERSION."\n"); $output->print(('=' x 60)."\n\n"); &load_config; } #'_stop' event sub main_stop { $output->close(); delete $_[HEAP]->{vnes}; } #Load ports-mapping config of virtual NEs sub load_config { $output->print(ts().", load ports-mapping config\n"); my $config_fh = new IO::File "$confdir/$pmconfig", "r"; while(<$config_fh>) { chomp; next if(m/^\s{0,}$/ or /^#/); my ($vid, $desc, $port) = split /\s+/, $_; $_[HEAP]->{vnes}->{$vid}->{desc} = $desc; $_[HEAP]->{vnes}->{$vid}->{port} = $port; } #print Dumper($_[HEAP]->{vnes}); $config_fh->close(); &create_queues; } #Create alarm queues sub create_queues { $output->print(ts().", create alarm queues\n"); $_[HEAP]->{vnes}->{$_}->{queue} = new Queue::Base foreach(keys %{$_[HEAP]->{vnes}}); #&dump_queues; $_[KERNEL]->yield('alarm_scanning'); $_[KERNEL]->yield('start_listen'); } #'alarm_scanning' event sub alarm_scanning { $output->print(ts().", scan alarm directory\n"); foreach my $vid (keys %{$_[HEAP]->{vnes}}) { $_[HEAP]->{vnes}->{$vid}->{alarm_files} = (); opendir(ALARMDIR, "$alarmdir/$vid"); foreach (sort{$a cmp $b} readdir(ALARMDIR)) { next if(not m/\.log$/i); push @{$_[HEAP]->{vnes}->{$vid}->{alarm_files}}, $_; } closedir(ALARMDIR); } #&dump_alarmfiles; $_[KERNEL]->yield('update_queues'); } #'update_queues' event sub update_queues { $output->print(ts().", update alarm queues\n"); foreach my $vid (keys %{$_[HEAP]->{vnes}}) { foreach my $alarmfile (@{$_[HEAP]->{vnes}->{$vid}->{alarm_files}}) { my @elems; my $alarmfh = new IO::File "$alarmdir/$vid/$alarmfile", "r"; chomp and push @elems, $_ while(<$alarmfh>); $alarmfh->close(); $_[HEAP]->{vnes}->{$vid}->{queue}->add(@elems); my $total_length = $_[HEAP]->{vnes}->{$vid}->{queue}->size(); $_[HEAP]->{vnes}->{$vid}->{queue}->remove($total_length - MAX_LENGTH) if($total_length > MAX_LENGTH); unlink("$alarmdir/$vid/$alarmfile"); } } #&dump_queues; $_[KERNEL]->delay('alarm_scanning' => SCANNING_TIMER); } #For debug sub dump_queues { foreach my $vid (keys %{$_[HEAP]->{vnes}}) { my $queue = $_[HEAP]->{vnes}->{$vid}->{queue}; print "Queue of $vid is empty\n" and next if($queue->empty()); my @elems = $queue->remove($queue->size()); print Dumper(\@elems); } } #For debug sub dump_alarmfiles { foreach (keys %{$_[HEAP]->{vnes}}) { print Dumper($_[HEAP]->{vnes}->{$_}->{alarm_files}); } } #'start_listen' event sub start_listen { $output->print(ts().", create listening wheels\n"); foreach my $vid (keys %{$_[HEAP]->{vnes}}) { $_[HEAP]->{vnes}->{$vid}->{listen_wheel} = POE::Wheel::SocketFactory->new( BindAddress => '127.0.0.1', BindPort => $_[HEAP]->{vnes}->{$vid}->{port}, SocketDomain => AF_INET, SocketType => SOCK_STREAM, ListenQueue => SOMAXCONN, SocketProtocol => 'tcp', Reuse => 'on', SuccessEvent => 'accept_success', FailureEvent => 'accept_failure', ); } } #'accept_success' event sub accept_success { my $accepted_handle = $_[ARG0]; my ($peer_addr, $peer_port, $listen_wid)= (inet_ntoa($_[ARG1]), $_[ARG2], $_[ARG3]); foreach my $vid (keys %{$_[HEAP]->{vnes}}) { if($_[HEAP]->{vnes}->{$vid}->{listen_wheel}->ID() == $listen_wid) { $output->print(ts().", vID:$vid connected from '$peer_addr:$peer_port'\n"); my $client_wheel = POE::Wheel::ReadWrite->new( Handle => $accepted_handle, Driver => POE::Driver::SysRW->new(), Filter => POE::Filter::Stream->new(), InputEvent => 'client_send', ErrorEvent => 'client_error', ); my $client_wid = $client_wheel->ID(); $_[HEAP]->{vnes}->{$vid}->{client_wheels}->{$client_wid} = $client_wheel; $_[KERNEL]->yield('client_send'); last; } } } #'accept_failure' event sub accept_failure { } #'client_send' event sub client_send { $output->print(ts().", send alarm queues\n"); foreach my $vid (keys %{$_[HEAP]->{vnes}}) { my $queue = $_[HEAP]->{vnes}->{$vid}->{queue}; if($queue->size()) { my @elems = $queue->remove($queue->size()); foreach my $client_wid (keys %{$_[HEAP]->{vnes}->{$vid}->{client_wheels}}) { $_[HEAP]->{vnes}->{$vid}->{client_wheels}->{$client_wid}->put("$_\n") foreach(@elems); } } } $_[KERNEL]->delay('client_send' => SENDING_TIMER); } #'client_error' event sub client_error { my $client_wid = $_[ARG3]; foreach my $vid (keys %{$_[HEAP]->{vnes}}) { if(defined $_[HEAP]->{vnes}->{$vid}->{client_wheels}->{$client_wid}) { $output->print(ts().", client wheel '$client_wid' of vID:$vid closed\n"); delete $_[HEAP]->{vnes}->{$vid}->{client_wheels}->{$client_wid}; } } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060814/a5bcab1f/attachment-0001.html From yang.liana at gmail.com Tue Aug 22 23:07:08 2006 From: yang.liana at gmail.com (=?gb2312?B?0e7P/sHB?=) Date: Wed, 23 Aug 2006 14:07:08 +0800 Subject: [PerlChina] wanna a regex expression Message-ID: <200608231407051252726@gmail.com> Hi, all! suppose a src string like this: how are you today ? "are you ok?" you are welcome! I want this string to be : how are hello today? "are you ok?" hello are welcome! I want to use just a regex express to do it. but i cant prevent from "are you ok?" being changed to be "are hello ok?". I want to use the *Look ahead* or *Look behind* to solve it. can I ? Yang.liana Aug/23/2006 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060823/1d879ddd/attachment.html From havel.zhang at gmail.com Wed Aug 23 04:32:54 2006 From: havel.zhang at gmail.com (Havel Zhang) Date: Wed, 23 Aug 2006 19:32:54 +0800 Subject: [PerlChina] wanna a regex expression In-Reply-To: <200608231407051252726@gmail.com> References: <200608231407051252726@gmail.com> Message-ID: hi yang: you can using (?!...) regex extension solve this problem. like follows: #--------------------- $a = 'how are you today ? "are you ok?" you are welcome!'; $a =~ s/you(?!\sok\?)/hello/ig; print $a ."\n"; #------------------- Outputs: how are hello today ? "are you ok?" hello are welcome! #------------------- other regEx extensions: (?= ... ) if match ahead successfully, return true. (?! ... ) if match ahead failed, return true. (?<= ...) if match backwards successfully, return true. (? wrote: > > Hi, all! > suppose a src string like this: how are you today ? "are you ok?" you > are welcome! > I want this string to be : how are hello today? "are you ok?" > hello are welcome! > > I want to use just a regex express to do it. but i cant prevent from > "are you ok?" being changed to be "are hello ok?". > I want to use the *Look ahead* or *Look behind* to solve it. can I ? > > Yang.liana > Aug/23/2006 > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > -- 真理使你自由 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060823/55d3e99d/attachment.html From wanliyou at gmail.com Wed Aug 23 19:25:08 2006 From: wanliyou at gmail.com (=?GB2312?B?hWSEXoVk?=) Date: Thu, 24 Aug 2006 10:25:08 +0800 Subject: [PerlChina] wanna a regex expression In-Reply-To: References: <200608231407051252726@gmail.com> Message-ID: <41143d8f0608231925t11032d2bvd2f17793ae64985d@mail.gmail.com> ~s# # #g ~s# # # Don't set it as global may help On 8/23/06, Havel Zhang wrote: > > hi yang: > > you can using (?!...) regex extension solve this problem. like > follows: > #--------------------- > $a = 'how are you today ? "are you ok?" you are welcome!'; > $a =~ s/you(?!\sok\?)/hello/ig; > print $a ."\n"; > #------------------- > Outputs: > how are hello today ? "are you ok?" hello are welcome! > #------------------- > > > other regEx extensions: > > (?= ... ) if match ahead successfully, return true. > (?! ... ) if match ahead failed, return true. > (?<= ...) if match backwards successfully, return true. > (? > Good, luck. :) > > Havel Zhang > > On 8/23/06, 杨晓亮 < yang.liana at gmail.com> wrote: > > > Hi, all! > suppose a src string like this: how are you today ? "are you ok?" you > are welcome! > I want this string to be : how are hello today? "are you ok?" > hello are welcome! > > I want to use just a regex express to do it. but i cant prevent from > "are you ok?" being changed to be "are hello ok?". > I want to use the *Look ahead* or *Look behind* to solve it. can I ? > > Yang.liana > Aug/23/2006 > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > > > > -- > 真理使你自由 > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > -- --==Best Regards From WanLi==-- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060824/f73c1251/attachment.html From havel.zhang at gmail.com Wed Aug 23 22:18:50 2006 From: havel.zhang at gmail.com (Havel Zhang) Date: Thu, 24 Aug 2006 13:18:50 +0800 Subject: [PerlChina] wanna a regex expression In-Reply-To: <41143d8f0608231925t11032d2bvd2f17793ae64985d@mail.gmail.com> References: <200608231407051252726@gmail.com> <41143d8f0608231925t11032d2bvd2f17793ae64985d@mail.gmail.com> Message-ID: hi wanliyou: don't set it as global, may ignore the last replacement. yang wang to change 'how are you today ? "are you ok?" you are welcome!' to ' how are hello today? "are you ok?" hello are welcome!' if you not using global, the last 'you' will be ignored. Havel Zhang On 8/24/06, �d�^�d wrote: > > ~s# # #g > > ~s# # # > > Don't set it as global may help > > > On 8/23/06, Havel Zhang wrote: > > > > hi yang: > > > > you can using (?!...) regex extension solve this problem. like > > follows: > > #--------------------- > > $a = 'how are you today ? "are you ok?" you are welcome!'; > > $a =~ s/you(?!\sok\?)/hello/ig; > > print $a ."\n"; > > #------------------- > > Outputs: > > how are hello today ? "are you ok?" hello are welcome! > > #------------------- > > > > > > other regEx extensions: > > > > (?= ... ) if match ahead successfully, return true. > > (?! ... ) if match ahead failed, return true. > > (?<= ...) if match backwards successfully, return true. > > (? > > > Good, luck. :) > > > > Havel Zhang > > > > On 8/23/06, ��� < yang.liana at gmail.com> wrote: > > > > > Hi, all! > > suppose a src string like this: how are you today ? "are you ok?" > > you are welcome! > > I want this string to be : how are hello today? "are you ok?" > > hello are welcome! > > > > I want to use just a regex express to do it. but i cant prevent > > from "are you ok?" being changed to be "are hello ok?". > > I want to use the *Look ahead* or *Look behind* to solve it. can I > > ? > > > > Yang.liana > > Aug/23/2006 > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > > > > > > -- > > ��ʹ��� > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > > -- > --==Best Regards From WanLi==-- > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > -- ��ʹ��� -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060824/90041120/attachment.html From wanliyou at gmail.com Wed Aug 23 22:23:48 2006 From: wanliyou at gmail.com (=?GB2312?B?hWSEXoVk?=) Date: Thu, 24 Aug 2006 13:23:48 +0800 Subject: [PerlChina] wanna a regex expression In-Reply-To: References: <200608231407051252726@gmail.com> <41143d8f0608231925t11032d2bvd2f17793ae64985d@mail.gmail.com> Message-ID: <41143d8f0608232223m7238fd87rc8af5c9cb9dfb5d6@mail.gmail.com> Sorry,I didn't see the problem clearly. Thanks for zhang's remind. :) On 8/24/06, Havel Zhang wrote: > > hi wanliyou: > don't set it as global, may ignore the last replacement. > yang wang to change 'how are you today ? "are you ok?" you are welcome!' to > ' how are hello today? "are you ok?" hello are welcome!' > if you not using global, the last 'you' will be ignored. > > Havel Zhang > > > > On 8/24/06, �d�^�d wrote: > > > > ~s# # #g > > > > ~s# # # > > > > Don't set it as global may help > > > > > > On 8/23/06, Havel Zhang wrote: > > > > > > hi yang: > > > > > > you can using (?!...) regex extension solve this problem. like > > > follows: > > > #--------------------- > > > $a = 'how are you today ? "are you ok?" you are welcome!'; > > > $a =~ s/you(?!\sok\?)/hello/ig; > > > print $a ."\n"; > > > #------------------- > > > Outputs: > > > how are hello today ? "are you ok?" hello are welcome! > > > #------------------- > > > > > > > > > other regEx extensions: > > > > > > (?= ... ) if match ahead successfully, return true. > > > (?! ... ) if match ahead failed, return true. > > > (?<= ...) if match backwards successfully, return true. > > > (? > > > > > Good, luck. :) > > > > > > Havel Zhang > > > > > > On 8/23/06, ��� < yang.liana at gmail.com > wrote: > > > > > > > Hi, all! > > > suppose a src string like this: how are you today ? "are you ok?" > > > you are welcome! > > > I want this string to be : how are hello today? "are you > > > ok?" hello are welcome! > > > > > > I want to use just a regex express to do it. but i cant prevent > > > from "are you ok?" being changed to be "are hello ok?". > > > I want to use the *Look ahead* or *Look behind* to solve it. can > > > I ? > > > > > > Yang.liana > > > Aug/23/2006 > > > > > > _______________________________________________ > > > China-pm mailing list > > > China-pm at pm.org > > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > > > > > > > > > > > -- > > > ��ʹ��� > > > > > > _______________________________________________ > > > China-pm mailing list > > > China-pm at pm.org > > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > > > > > > > -- > > --==Best Regards From WanLi==-- > > > > _______________________________________________ > > China-pm mailing list > > China-pm at pm.org > > http://mail.pm.org/mailman/listinfo/china-pm > > > > > > -- > ��ʹ��� > > _______________________________________________ > China-pm mailing list > China-pm at pm.org > http://mail.pm.org/mailman/listinfo/china-pm > -- ------======Nerazzurri======------ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060824/dd97f950/attachment-0001.html From yang.liana at gmail.com Wed Aug 23 22:26:37 2006 From: yang.liana at gmail.com (=?gb2312?B?0e7P/sHB?=) Date: Thu, 24 Aug 2006 13:26:37 +0800 Subject: [PerlChina] wanna a regex expression References: <200608231407051252726@gmail.com> <41143d8f0608231925t11032d2bvd2f17793ae64985d@mail.gmail.com> Message-ID: <200608241326315158355@gmail.com> Yes, what I wanted was to use (?!...), (?=...) or (?<=...) and so on to resolve this. I believe the Power of perl regex expression. Thank you for the helping of Havel Zhang and Wanliyou :-) Yang.liana Aug/24/2006 ������� Havel Zhang ���ʱ�䣺 2006-08-24 13:19:18 ������ china-pm at pm.org ����� ���� Re: [PerlChina] wanna a regex expression hi wanliyou: don't set it as global, may ignore the last replacement. yang wang to change 'how are you today ? "are you ok?" you are welcome!' to ' how are hello today? "are you ok?" hello are welcome!' if you not using global, the last 'you' will be ignored. Havel Zhang On 8/24/06, �d�^�d wrote: ~s# # #g ~s# # # Don't set it as global may help On 8/23/06, Havel Zhang wrote: hi yang: you can using (?!...) regex extension solve this problem. like follows: #--------------------- $a = 'how are you today ? "are you ok?" you are welcome!'; $a =~ s/you(?!\sok\?)/hello/ig; print $a ."\n"; #------------------- Outputs: how are hello today ? "are you ok?" hello are welcome! #------------------- other regEx extensions: (?= ... ) if match ahead successfully, return true. (?! ... ) if match ahead failed, return true. (?<= ...) if match backwards successfully, return true. (? wrote: Hi, all! suppose a src string like this: how are you today ? "are you ok?" you are welcome! I want this string to be : how are hello today? "are you ok?" hello are welcome! I want to use just a regex express to do it. but i cant prevent from "are you ok?" being changed to be "are hello ok?". I want to use the *Look ahead* or *Look behind* to solve it. can I ? Yang.liana Aug/23/2006 _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm -- ��ʹ��� _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm -- --==Best Regards From WanLi==-- _______________________________________________ China-pm mailing list China-pm at pm.org http://mail.pm.org/mailman/listinfo/china-pm -- ��ʹ��� -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/china-pm/attachments/20060824/1bce1fc3/attachment.html