在打开函数的第一个参数后,我在Perl Missing逗号中出错

问题描述 投票:-1回答:2

我正在尝试创建一个数据库perl程序。但我得到这个错误:

Missing comma after first argument to open function at database-txt.pl line 15, near "">$name.pswrd";"
Missing comma after first argument to open function at database-txt.pl line 25, near ""$a.nme";"
Missing comma after first argument to open function at database-txt.pl line 30, near ""$a.pswrd";"

谢谢!

sub change {
    my($a) = @_;
    chdir "$a" or die "ERROR: $!";
}
print "Do you want to register or log-in? "; chomp($a=<STDIN>);
if($a =~ /register/i) {
      print "What is your name: "; chomp($name=<STDIN>);
      print "What is your password: "; chomp($password=<STDIN>);
      change "name";
      open NAME, ">$name.nme";
      print NAME "$name";
      close NAME;
      change "..";
      change "password";
      open PASSWORD ">$name.pswrd";
      print PASSWORD "$password";
      close PASSWORD;
      change "..";
      print "Complete.\n";
}
else {
      print "Name: "; chomp($a=<STDIN>);
      print "Password: "; chomp($b=<STDIN>);
      change "name";
      open NAME "$a.nme";
      $c=<NAME>;
      close NAME;
      change "..";
      change "password";
      open PASSWORD "$a.pswrd";
      $d=<PASSWORD>;
      PASSWORD;
      "..";
}
if($a =~ /$c/ and $b =~ /$d/) {
      print "Log-in successful!\n";
      sleep(2);
      print  "Hello, $a!\n";
}
database perl text
2个回答
2
投票
open NAME "$a.nme";

应该

open NAME, "$a.nme";

顺便说一句,我强烈建议您使用代码reviewed。可以进行许多改进。


-3
投票

你忘记了()

打开(NAME,“> $ name.pswrd”);

关闭(NAME);

© www.soinside.com 2019 - 2024. All rights reserved.