哦,确实是这样。
多谢

以前是将chomp放在单独行,看来不能盲目简化。。

2009/7/15 xsir317 <[email protected]>

>  MYCODE 一共就25行,读完了就没了。你去chomp一个空变量当然报错。
>
> 应该是
>  while (my $mycode=<MYCODE>) {
> chomp  $mycode;
> }
>
> 这样就可以了
>
> 2009-07-15
> ------------------------------
>   *中华连珠网* <http://www.shwzq.com>
>
> *五子棋百科* <http://www.shwzq.com/wiki>
> ------------------------------
> *发件人:* smallfish.xy
> *发送时间:* 2009-07-15  10:11:25
> *收件人:* perlchina
> *抄送:*
> *主题:* [PerlChina] Re: while未初始化变量的问题
>  放到while之外定义
> --
> http://hi.baidu.com/smallfish_xy
> http://code.google.com/p/smallfish/
>
>
> 2009/7/15 Ericzhao82 <[email protected]>
>
>> 大家如何解决while循环时,变量未初始化的问题?
>>
>> 例如
>>                         while (chomp(my $mycode=<MYCODE>)) {
>> }
>>
>> 弹出警告信息
>>
>> Use of uninitialized value in chomp at my.pl line 26, <MYCODE> line 26.
>>
>>
>>
>>
>>
> >
>


-- 
…………………………………………
              Ericzhao

Email:   [email protected]
MSN:    [email protected]
BLOG:   share82.freebsder.info

--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛“PerlChina Mongers 讨论组”论坛。
 要在此论坛发帖,请发电子邮件到 [email protected]
 要退订此论坛,请发邮件至 [email protected]
 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

回复