2011年1月6日星期四

Re: [PerlChina] 一个关于配置刷选的问题

非常感谢,要的就是这个效果。





======= 2011-01-06 18:03 Fayland Lam 您在来信中写到:Re: [PerlChina] 一个关于配置刷选的问题 =======

that's pretty simple like:

my $section_now;
my (@messages, @mail_log, @apache_log);
while (my $line = <$fh>) {
if ($line =~ /^(\-+)messages(\-+)$/) {
$section_now = 'messages'; next;
} elsif ($line =~ /^(\-+)apache\-log(\-+)$/) {
$section_now = 'apache-log'; next;
} elsif ($line =~ s/^(\#+)mail\-log(\#+)$/) {
$section_now = 'mail-log'; next;
}
next unless $section_now; # before ---messages---
next if $line =~ /^\#+$/; the ########## line
if ($section_now eq 'message') {
push @messages, $line;
} elsif ($section eq 'apache-log') {
push @apache_log, $line;
}
}

OK. untested. but basically the above should work for you.

Thanks

2011/1/6 Gary.jsz <gary.jsz@gmail.com>:
> 大家好!
>
> 有个问题比较疑惑,不知道怎么处理了,还请指点指点。
>
> 我有一个文件,内容如下:
>
> ----------messages----------------
> Jan 9 05:30:13 linux-lhkq sshd[5118]: Accepted keyboard-interactive/pam for
> root from 192.168.44.1 port 2394 ssh2
> Jan 9 06:01:25 linux-lhkq syslog-ng[3412]: STATS: dropped 0
> Jan 9 06:01:38 linux-lhkq zmd: ShutdownManager (WARN): Preparing to
> sleep...
> Jan 9 06:01:38 linux-lhkq zmd: ShutdownManager (WARN): Going to sleep,
> waking up at 01/10/2011 04:51:38
> Jan 9 06:31:00 linux-lhkq kernel: ISO 9660 Extensions: Microsoft Joliet
> Level 3
> Jan 9 06:31:00 linux-lhkq kernel: ISO 9660 Extensions: RRIP_1991A
> Jan 9 06:56:50 linux-lhkq shadow[9035]: group is unknown - group=wwwadmin,
> by=0
> Jan 9 06:56:50 linux-lhkq shadow[9036]: default group changed -
> account=wwwrun, uid=30, gid=8, old gid=8, by=0
> Jan 9 06:56:50 linux-lhkq shadow[9037]: shell changed - account=wwwrun,
> uid=30, shell=/bin/false, old shell=/bin/false, by=0
> Jan 9 07:01:25 linux-lhkq syslog-ng[3412]: STATS: dropped 0
>
>
> ----------apache-log----------------
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:06 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
>
>
> ######################################################
> ###############mail-log###############################
> Jan 3 19:21:17 linux-lhkq postfix/postfix-script: starting the Postfix mail
> system
> Jan 3 19:21:17 linux-lhkq postfix/master[4648]: daemon started -- version
> 2.2.9, configuration /etc/postfix
> Jan 4 14:16:41 linux-lhkq postfix/postfix-script: starting the Postfix mail
> system
> Jan 4 14:16:42 linux-lhkq postfix/master[4632]: daemon started -- version
> 2.2.9, configuration /etc/postfix
> Jan 4 15:52:46 linux-lhkq postfix/master[4632]: terminating on signal 15
> Jan 7 19:19:58 linux-lhkq postfix/postfix-script: starting the Postfix mail
> system
> Jan 7 19:19:59 linux-lhkq postfix/master[4628]: daemon started -- version
> 2.2.9, configuration /etc/postfix
> Jan 7 19:24:37 linux-lhkq postfix/master[4628]: terminating on signal 15
> Jan 9 05:01:32 linux-lhkq postfix/postfix-script: starting the Postfix mail
> system
> Jan 9 05:01:33 linux-lhkq postfix/master[4573]: daemon started -- version
> 2.2.9, configuration /etc/postfix
>
>
>
> 我想把各个块下面的内容输出到一个列表,不知道怎么操作。
>
> 结果如:
>
> @messages的内容是 messages段下面(apache-log上面)的内容
> @apache-log的内容为apache-log与mail-log之间的内容
> .......
>
>
>
> 先谢谢了!
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>



--
Fayland Lam // http://www.fayland.org/

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

.


= = = = = = = = = = = = = = = = = = = =


深圳市傲冠软件股份有限公司      运营部       蒋士竹
----------------------------------------------------------
Address:  深圳市福田区深南大道6015号本元大厦16楼    518040
Tel:  (0)13816642255        MSN:  gary.jsz@gmail.com
Email: jsz@skybility.com    Website: www.skybility.com 

Re: [PerlChina] 一个关于配置刷选的问题

that's pretty simple like:

my $section_now;
my (@messages, @mail_log, @apache_log);
while (my $line = <$fh>) {
if ($line =~ /^(\-+)messages(\-+)$/) {
$section_now = 'messages'; next;
} elsif ($line =~ /^(\-+)apache\-log(\-+)$/) {
$section_now = 'apache-log'; next;
} elsif ($line =~ s/^(\#+)mail\-log(\#+)$/) {
$section_now = 'mail-log'; next;
}
next unless $section_now; # before ---messages---
next if $line =~ /^\#+$/; the ########## line
if ($section_now eq 'message') {
push @messages, $line;
} elsif ($section eq 'apache-log') {
push @apache_log, $line;
}
}

OK. untested. but basically the above should work for you.

Thanks

2011/1/6 Gary.jsz <gary.jsz@gmail.com>:
> 大家好!
>
> 有个问题比较疑惑,不知道怎么处理了,还请指点指点。
>
> 我有一个文件,内容如下:
>
> ----------messages----------------
> Jan 9 05:30:13 linux-lhkq sshd[5118]: Accepted keyboard-interactive/pam for
> root from 192.168.44.1 port 2394 ssh2
> Jan 9 06:01:25 linux-lhkq syslog-ng[3412]: STATS: dropped 0
> Jan 9 06:01:38 linux-lhkq zmd: ShutdownManager (WARN): Preparing to
> sleep...
> Jan 9 06:01:38 linux-lhkq zmd: ShutdownManager (WARN): Going to sleep,
> waking up at 01/10/2011 04:51:38
> Jan 9 06:31:00 linux-lhkq kernel: ISO 9660 Extensions: Microsoft Joliet
> Level 3
> Jan 9 06:31:00 linux-lhkq kernel: ISO 9660 Extensions: RRIP_1991A
> Jan 9 06:56:50 linux-lhkq shadow[9035]: group is unknown - group=wwwadmin,
> by=0
> Jan 9 06:56:50 linux-lhkq shadow[9036]: default group changed -
> account=wwwrun, uid=30, gid=8, old gid=8, by=0
> Jan 9 06:56:50 linux-lhkq shadow[9037]: shell changed - account=wwwrun,
> uid=30, shell=/bin/false, old shell=/bin/false, by=0
> Jan 9 07:01:25 linux-lhkq syslog-ng[3412]: STATS: dropped 0
>
>
> ----------apache-log----------------
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:06 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
> 127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-"
> "ApacheBench/2.0.40-dev"
>
>
> ######################################################
> ###############mail-log###############################
> Jan 3 19:21:17 linux-lhkq postfix/postfix-script: starting the Postfix mail
> system
> Jan 3 19:21:17 linux-lhkq postfix/master[4648]: daemon started -- version
> 2.2.9, configuration /etc/postfix
> Jan 4 14:16:41 linux-lhkq postfix/postfix-script: starting the Postfix mail
> system
> Jan 4 14:16:42 linux-lhkq postfix/master[4632]: daemon started -- version
> 2.2.9, configuration /etc/postfix
> Jan 4 15:52:46 linux-lhkq postfix/master[4632]: terminating on signal 15
> Jan 7 19:19:58 linux-lhkq postfix/postfix-script: starting the Postfix mail
> system
> Jan 7 19:19:59 linux-lhkq postfix/master[4628]: daemon started -- version
> 2.2.9, configuration /etc/postfix
> Jan 7 19:24:37 linux-lhkq postfix/master[4628]: terminating on signal 15
> Jan 9 05:01:32 linux-lhkq postfix/postfix-script: starting the Postfix mail
> system
> Jan 9 05:01:33 linux-lhkq postfix/master[4573]: daemon started -- version
> 2.2.9, configuration /etc/postfix
>
>
>
> 我想把各个块下面的内容输出到一个列表,不知道怎么操作。
>
> 结果如:
>
> @messages的内容是 messages段下面(apache-log上面)的内容
> @apache-log的内容为apache-log与mail-log之间的内容
> .......
>
>
>
> 先谢谢了!
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>

--
Fayland Lam // http://www.fayland.org/

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

[PerlChina] 一个关于配置刷选的问题

大家好!
    
    有个问题比较疑惑,不知道怎么处理了,还请指点指点。

我有一个文件,内容如下:

----------messages----------------
Jan  9 05:30:13 linux-lhkq sshd[5118]: Accepted keyboard-interactive/pam for root from 192.168.44.1 port 2394 ssh2
Jan  9 06:01:25 linux-lhkq syslog-ng[3412]: STATS: dropped 0
Jan  9 06:01:38 linux-lhkq zmd: ShutdownManager (WARN): Preparing to sleep...
Jan  9 06:01:38 linux-lhkq zmd: ShutdownManager (WARN): Going to sleep, waking up at 01/10/2011 04:51:38
Jan  9 06:31:00 linux-lhkq kernel: ISO 9660 Extensions: Microsoft Joliet Level 3
Jan  9 06:31:00 linux-lhkq kernel: ISO 9660 Extensions: RRIP_1991A
Jan  9 06:56:50 linux-lhkq shadow[9035]: group is unknown - group=wwwadmin, by=0
Jan  9 06:56:50 linux-lhkq shadow[9036]: default group changed - account=wwwrun, uid=30, gid=8, old gid=8, by=0
Jan  9 06:56:50 linux-lhkq shadow[9037]: shell changed - account=wwwrun, uid=30, shell=/bin/false, old shell=/bin/false, by=0
Jan  9 07:01:25 linux-lhkq syslog-ng[3412]: STATS: dropped 0


----------apache-log----------------
127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-" "ApacheBench/2.0.40-dev"
127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-" "ApacheBench/2.0.40-dev"
127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-" "ApacheBench/2.0.40-dev"
127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-" "ApacheBench/2.0.40-dev"
127.0.0.1 - - [09/Jan/2011:07:00:06 +0800] "GET / HTTP/1.0" 403 1045 "-" "ApacheBench/2.0.40-dev"
127.0.0.1 - - [09/Jan/2011:07:00:16 +0800] "GET / HTTP/1.0" 403 1045 "-" "ApacheBench/2.0.40-dev"


######################################################
###############mail-log###############################
Jan  3 19:21:17 linux-lhkq postfix/postfix-script: starting the Postfix mail system
Jan  3 19:21:17 linux-lhkq postfix/master[4648]: daemon started -- version 2.2.9, configuration /etc/postfix
Jan  4 14:16:41 linux-lhkq postfix/postfix-script: starting the Postfix mail system
Jan  4 14:16:42 linux-lhkq postfix/master[4632]: daemon started -- version 2.2.9, configuration /etc/postfix
Jan  4 15:52:46 linux-lhkq postfix/master[4632]: terminating on signal 15
Jan  7 19:19:58 linux-lhkq postfix/postfix-script: starting the Postfix mail system
Jan  7 19:19:59 linux-lhkq postfix/master[4628]: daemon started -- version 2.2.9, configuration /etc/postfix
Jan  7 19:24:37 linux-lhkq postfix/master[4628]: terminating on signal 15
Jan  9 05:01:32 linux-lhkq postfix/postfix-script: starting the Postfix mail system
Jan  9 05:01:33 linux-lhkq postfix/master[4573]: daemon started -- version 2.2.9, configuration /etc/postfix



我想把各个块下面的内容输出到一个列表,不知道怎么操作。

结果如:

@messages的内容是 messages段下面(apache-log上面)的内容
@apache-log的内容为apache-log与mail-log之间的内容
.......



先谢谢了!

2011年1月2日星期日

Re: [PerlChina] Perl对各种媒介的格式化输出

I'm not sure if this one can do the job or not:

http://search.cpan.org/~chorny/Text-Reform-1.20/lib/Text/Reform.pm

but it looks complicated.

maybe you can try to write an excel first, then export as txt or pdf.

Thanks

On 2011/1/2 22:58, Beckheng Lam wrote:
大家好!

好久没发信向大家请教问题了!
我最近在开发一个功能,将繁体文字转为简体,并可选输出对应的汉字拼音!
现在用到如下的模块,分别对应于: 1, 繁转简; 2, 汉字转拼音(带声调-数字); 3, 拼音(带声调-数字)转可视化拼音格式。

use Encode::HanConvert;(唐凤)
use Lingua::Han::PinYin;(Fayland Lam)
use Lingua::Han::CanonicalPinYin;(孙海军)

现在有涉及格式化输出的问题想请教一下:
我现在网页上输出,使用了表格的形式,感觉还行。
效果如下:
zhū fǎ cóng zòng zōng cōng yuán yuàn qǐ   rú lái lài shuō shuì tuō yuè shì yīn  
诸 法 从 缘 起 , 如 来 说 是 因 。
bǐ fǎ yīn yuán yuàn jǐn   shì dà dài tài shā shà suō mén shuō shuì tuō yuè  
彼 法 因 缘 尽 , 是 大 沙 门 说 。

像大家看到的,这是第一次出来的结果,还需要手动校对多音字后才是预期的最终结果。
如下面的,

zhū fǎ cóng yuán qǐ   rú lái  shuō
shì yīn  
诸 法 从 缘 起 , 如 来 说 是 因 。
bǐ fǎ yīn yuán jǐn   shì dà  shā  mén shuō
 
彼 法 因 缘 尽 , 是 大 沙 门 说 。

但对于输出为txt,或者pdf,还是直接到A4纸打印的,像上面汉字与拼音一一对应的,不知道有什么好的方法?

另外有一点,在多音字不能尽确定的情况下,手动校对多音字是必然的,所以输出格式,对于手动编辑的影响,可能也是有的。

欢迎任何长度的方法提议,谢谢大家了!

--  Perl乐事 -- http://www.perlersh.org 我的博客 -- http://www.perlersh.org/blog.html 诸法从缘起,如来说是因。 彼法因缘尽,是大沙门说。
--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。


--  Fayland Lam // http://www.fayland.org/

[PerlChina] Perl对各种媒介的格式化输出

大家好!

好久没发信向大家请教问题了!
我最近在开发一个功能,将繁体文字转为简体,并可选输出对应的汉字拼音!
现在用到如下的模块,分别对应于: 1, 繁转简; 2, 汉字转拼音(带声调-数字); 3, 拼音(带声调-数字)转可视化拼音格式。

use Encode::HanConvert;(唐凤)
use Lingua::Han::PinYin;(Fayland Lam)
use Lingua::Han::CanonicalPinYin;(孙海军)

现在有涉及格式化输出的问题想请教一下:
我现在网页上输出,使用了表格的形式,感觉还行。
效果如下:
zhū fǎ cóng zòng zōng cōng yuán yuàn qǐ   rú lái lài shuō shuì tuō yuè shì yīn  
诸 法 从 缘 起 , 如 来 说 是 因 。
bǐ fǎ yīn yuán yuàn jǐn   shì dà dài tài shā shà suō mén shuō shuì tuō yuè  
彼 法 因 缘 尽 , 是 大 沙 门 说 。

像大家看到的,这是第一次出来的结果,还需要手动校对多音字后才是预期的最终结果。
如下面的,

zhū fǎ cóng yuán qǐ   rú lái  shuō
shì yīn  
诸 法 从 缘 起 , 如 来 说 是 因 。
bǐ fǎ yīn yuán jǐn   shì dà  shā  mén shuō
 
彼 法 因 缘 尽 , 是 大 沙 门 说 。

但对于输出为txt,或者pdf,还是直接到A4纸打印的,像上面汉字与拼音一一对应的,不知道有什么好的方法?

另外有一点,在多音字不能尽确定的情况下,手动校对多音字是必然的,所以输出格式,对于手动编辑的影响,可能也是有的。

欢迎任何长度的方法提议,谢谢大家了!

--  Perl乐事 -- http://www.perlersh.org 我的博客 -- http://www.perlersh.org/blog.html 诸法从缘起,如来说是因。 彼法因缘尽,是大沙门说。