[PerlChina] 请教一个读文件的问题
潘建锋
panjianfeng1979 at gmail.com
Fri Jul 14 21:55:06 PDT 2006
虽然我最近打算学ICE――和你说的icesword好像没有什么关系,但应该不是你说的那个潘建锋:-)
在06-7-15,king sir <kangxiong at gmail.com> 写道:
>
> 潘建锋是icesword的潘建锋吗?
>
> 在06-7-14,islue <islue.hu at gmail.com> 写道:
>
> > while () {
> > next unless $_;
> > }
> > 从你的描述看,加这么一行应该ok了
> >
> > 在06-7-14,潘建锋 <panjianfeng1979 at gmail.com > 写道:
> > >
> > > 我现在有个文件类似
> > > struct C {
> > > a=..;
> > > b=..;
> > > c=..;
> > > d=..;
> > > }
> > > struct C {
> > > a=..;
> > > b=..;
> > > c=..;
> > > d=..
> > > }
> > > ...
> > > 我要读出每个结构的a和c值
> > > 我用了
> > > my $condition=0;
> > > while(<FILE>) {
> > > if (/a=(.+)/) {
> > > $arr[0] = $1;
> > > condition = 1;
> > > } elsif(condition == 1 && /c=(.+)/) {
> > > $arr[1] = $1
> > > condition = 0;
> > > # 往数据库插入@arr
> > > }
> > > }
> > > 这样只能得到第一个struct的数据,然后提示
> > > Use of uninitialized value in pattern match (m//) at ...
> > >
> > > <china-pm at pm.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
> >
>
>
>
> _______________________________________________
> 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/20060715/851e26a3/attachment.html
More information about the China-pm
mailing list