[PerlChina] China-pm Digest, Vol 43, Issue 23

owen nirvana freeespeech at gmail.com
Tue Mar 3 07:25:28 PST 2009


> my ($name, $title);
> while (<>){
> if (/^(\d+)\s+(.*)$) {
> if ($name) {
>  // 保存上一个 save $name, $title
>  // 下面开始处理一个新的
> $name = '';
> $title = '';
> }
> $name = $1;
> $title .= $2;
> } elsif(/^\s+(.*)$/) {
> $title .= $1;
> }
> // save last one

把自己的老问题翻上来,今天突然发现如果不是elsif, 而是else, 就只有匹配行的第二行会被合并,下一行就不会, why
gtalk:freeespeech at gmail.com



2008/11/18  <china-pm-request at pm.org>:
> Send China-pm mailing list submissions to
>        china-pm at pm.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.pm.org/mailman/listinfo/china-pm
> or, via email, send a message with subject or body 'help' to
>        china-pm-request at pm.org
>
> You can reach the person managing the list at
>        china-pm-owner at pm.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of China-pm digest..."
>
>
> Today's Topics:
>
>   1. Re:  China-pm Digest, Vol 43, Issue 21 (truncatei)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 17 Nov 2008 22:01:40 +0800
> From: truncatei <truncatei at gmail.com>
> Subject: Re: [PerlChina] China-pm Digest, Vol 43, Issue 21
> To: china-pm at pm.org
> Message-ID:
>        <c0d775f40811170601m6c2437aeyc2a3c19e7fe0a82e at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> 2008/11/17 owen nirvana <freeespeech at gmail.com>
>
>> 谢谢,问题是归到上一行这样的操作,我不知道如何用正则表达式完成,那不等于是让表达式再回溯吗
>> gtalk:freeespeech at gmail.com <gtalk%3Afreeespeech at gmail.com>
>>
>>
>> >>
>> >>
>> >> 还有一个问题,是关于提取数据的
>> >>
>> >> 2222  eewweasdds,asdasd.sadsadasdas
>> >>          ddasdddddddddddddddddddda
>> >>          ddddddddddddddddddddddddddd
>> >> 2821  easdddddddddddddddddddddddd
>> >> 2192  288888888888888888888ass0a-das.
>> >>          as;dddsaddaa0---------22222222
>> >>
>> >> 诸如此类,左边很好办,可是右边并不限于单行,我该如何把这样的数据提取为  name title的格式存到数据表里呢
>>
>> <http://mail.pm.org/mailman/listinfo/china-pm>
>
>
>
> my ($name, $title);
> while (<>){
> if (/^(\d+)\s+(.*)$) {
> if ($name) {
>  // 保存上一个 save $name, $title
>  // 下面开始处理一个新的
> $name = '';
> $title = '';
> }
> $name = $1;
> $title .= $2;
> } elsif(/^\s+(.*)$/) {
> $title .= $1;
> }
> // save last one
>
> 好久不写了,上面的代码或许会有些错误,大概的流程整理出来了:
> 每次遇到数字就开始一条数据,否则视为向当前数据中添加title
>
>
> --
> "老是呆在那里不好,我们随生活需要四处迁徙,多年以来的梦想,至今还未实现,压力堵塞了我们的耳朵,工作生涯到了尽头,还是一无所有,我们应该给后人留下点儿什么,教训是不会刻在纪念碑上的,光荣的命令和指引之手,也可请求,简单地改变一下角度就足够了"
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.pm.org/pipermail/china-pm/attachments/20081117/e8fdbb3d/attachment-0001.html>
>
> ------------------------------
>
> _______________________________________________
> China-pm mailing list
> China-pm at pm.org
> http://mail.pm.org/mailman/listinfo/china-pm
>
> End of China-pm Digest, Vol 43, Issue 23
> ****************************************
>


More information about the China-pm mailing list