因为在第二行,#! 所有的魔力就失效了,变成了一个无用的注释。
2009/8/30 linhy <[email protected]> > 再用IO::Prompt的时候,碰到一个很费解的问题?脚本的第一行是"#! /usr/bin/perl -w“的时候。尽管脚本可以运行, 会给 > 出警告信息: > > Use of uninitialized value $_ in pattern match (m//) at /usr/local/ > lib/perl5/site_perl/5.10.0/IO/Prompt.pm line 91. > > 若将第一行空着,把"#! /usr/bin/perl -w“放到第二行的时候,警告信息就消失了。不知道为什么?兄弟姐妹们碰到过吗?请指点一下。 > 详细情况如下: > > > [li...@genome2 Practice]$ cat -n iotry2.pl > 1 #! /usr/bin/perl -w > 2 # > 3 use strict; > 4 use warnings; > 5 use IO::Prompt; > 6 > 7 prompt ("print paswd: " , -tty, -echo => '*') or die "Error: > $!"; > 8 > 9 print "You passwd is: '$_'\n"; > 10 > 11 exit ; > > [li...@genome2 Practice]$ perl iotry2.pl > Use of uninitialized value $_ in pattern match (m//) at /usr/local/lib/ > perl5/site_perl/5.10.0/IO/Prompt.pm line 91. > print paswd: ** > You passwd is: 'll' > > 若将第一行空着,把"#! /usr/bin/perl -w“放到第二行的时候,警告信息就消失了。 > [li...@genome2 Practice]$ cat -n iotry3.pl > 1 > 2 #! /usr/bin/perl -w > 3 # > 4 use strict; > 5 use warnings; > 6 use IO::Prompt; > 7 > 8 prompt ("print paswd: " , -tty, -echo => '*') or die "Error: > $!"; > 9 > 10 print "You passwd is: '$_'\n"; > 11 > 12 exit ; > [li...@genome2 Practice]$ perl iotry3.pl > print paswd: *** > You passwd is: 'lll' > > > > --~--~---------~--~----~------------~-------~--~----~ 您收到此信息是由于您订阅了 Google 论坛“PerlChina Mongers 讨论组”论坛。 要在此论坛发帖,请发电子邮件到 [email protected] 要退订此论坛,请发邮件至 [email protected] 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛 -~----------~----~----~----~------~----~------~--~---
