2009年7月29日星期三

[PerlChina] 请教关于IO::Prompt使用问题

大家好。我学习perl没有多久。我在使用模块"IO::Prompt"的时候碰到两个对我来说是"未解之谜"的问题(^_^)。请大家指点一下。谢
谢。问题描述如下。
Hello! Everyone. I'm a newbie in perl. I have encountered two problems
that puzzling me. Could you give me some suggestions. Thanks. The
problems I encountered are:

我用的操作系统是Fedor core 10 (linux). Perl 的版本是v5.10.0。
The OS I used is Linux (Fedor core 10). The version of perl is
"v5.10.0"

问题一:不加参数好像正常,但如果加一下参数的话,会出现提示"Can't open add: No such file or
directory at iotry1.pl line 7" 代码和运行结果如下:
Question 1: It seems work normaly without anything except script name,
but warning "Can't open add: No such file or directory at iotry1.pl
line 7" will appear on screen when something following script name.
The code and running resuls are:

======================================================
[linhy@genome2 BatchPrimer3.extension]$ more iotry1.pl
#!/usr/bin/perl -w
#
use strict;
use warnings;
use IO::Prompt;

prompt ("print paswd: " ) or die "Error: $!";
print "You passwd is: '$_'\n";

[linhy@genome2 BatchPrimer3.extension]$ perl iotry1.pl
print paswd: hello
You passwd is: 'hello'
[linhy@genome2 BatchPrimer3.extension]$ perl iotry1.pl some arguments
Can't open some: No such file or directory at iotry1.pl line 7
[linhy@genome2 BatchPrimer3.extension]$
=======================================================


问题二: 在"prompt"中加"-echo => '*' "后,虽然可以工作,但是会给出警告:"Use of Uninitialized
value $_ in pattern match (m//) at /usr/local/lib/perl5/sit_perl/
5.10.0/IO/Prompt.pm"代码和结果如下:
Question 2: When adding option "-echo", it can work, but message "Use
of Uninitialized value $_ in pattern match (m//) at /usr/local/lib/
perl5/sit_perl/5.10.0/IO/Prompt.pm" will appear. The code and running
results are:

===================================================
[linhy@genome2 BatchPrimer3.extension]$ more iotry2.pl
#!/usr/bin/perl -w
#
use strict;
use warnings;
use IO::Prompt;

prompt ("print paswd: " ,
-echo => '*') or die "Error: $!";

print "You passwd is: '$_'\n";

exit ;

[linhy@genome2 BatchPrimer3.extension]$ 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: 'hello'
[linhy@genome2 BatchPrimer3.extension]$

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

没有评论: