Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法停止perl_Perl - Fatal编程技术网

无法停止perl

无法停止perl,perl,Perl,我有一个机器人。我的机器人加载到IRC上。 我在我的机器人中加入了全球信用,比如100信用。每个人使用我的机器人,信用都会下降 例如: Falcon check credit 99 Handy check credit 98 A check credit 97 在这种情况下,我想如果信用已经达到零,机器人应该停止检查。但如果下一步已到达0 bot停止,则如果信用到达-1,bot将再次工作 我的信用像这样倒计时 open(FILE, "+<freecredit.txt") or d

我有一个机器人。我的机器人加载到IRC上。 我在我的机器人中加入了全球信用,比如100信用。每个人使用我的机器人,信用都会下降

例如:

Falcon check credit 99
Handy check credit 98
A check credit 97
在这种情况下,我想如果信用已经达到零,机器人应该停止检查。但如果下一步已到达0 bot停止,则如果信用到达-1,bot将再次工作

我的信用像这样倒计时

    open(FILE, "+<freecredit.txt") or die "$! error";
    undef $/; 
    $number = <FILE>;
    $number = int($number);
    $credits = $number-1;
    seek(FILE, 0, 0); 
    truncate(FILE, tell FILE);
    print FILE $credits;
    close(FILE);

    if($credits == 0) {
    &respond_to_privmsg(\%msg,"Error : you must have credits to check");
    goto toEnd;
    }
    }

toEnd;

open(FILE),“+您的代码布局非常糟糕,似乎是一个循环的结尾,因此很难判断它应该是什么样子。您似乎在编写它时没有在开始时使用严格的
使用警告:要么这样,要么在文件顶部声明了所有内容,这也是一个坏主意

这可能对你有帮助

  open my $fh, '+<', 'freecredit.txt' or die "$! error";
  my $credits = <$fh>;

  if ($credits == 0) {
    respond_to_privmsg(\%msg, "Error : you must have credits to check");
    last;
  }

  $credits -= 1;

  truncate $fh, 0;
  seek $fh, 0, 0;
  print $fh $credits;
  close $fh;
}

打开我的$fh,“+你的代码布局非常糟糕,似乎是一个循环的结尾,因此很难说它应该是什么样子。你似乎在开始时没有使用
严格
使用警告
:或者你在文件顶部声明了所有内容,这也是一个坏主意

这可能对你有帮助

  open my $fh, '+<', 'freecredit.txt' or die "$! error";
  my $credits = <$fh>;

  if ($credits == 0) {
    respond_to_privmsg(\%msg, "Error : you must have credits to check");
    last;
  }

  $credits -= 1;

  truncate $fh, 0;
  seek $fh, 0, 0;
  print $fh $credits;
  close $fh;
}

打开我的$fh,+我已经使用了你的脚本,但是看到这样的ms:

    open my $fh, '+<', 'freecredit.txt' or die "$! error";
  my $credits = <$fh>;

  if ($credits == 0) {
print $credits;
    last;
  }

  $credits -= 1;

  truncate $fh, 0;
  seek $fh, 0, 0;
  print $fh $credits;
  close $fh;

打开我的$fh,+我已经使用了你的脚本,但是看到这样的ms:

    open my $fh, '+<', 'freecredit.txt' or die "$! error";
  my $credits = <$fh>;

  if ($credits == 0) {
print $credits;
    last;
  }

  $credits -= 1;

  truncate $fh, 0;
  seek $fh, 0, 0;
  print $fh $credits;
  close $fh;

打开我的$fh,+
如果(!$number){..不要减量..}
BTW我认为标签
toEnd;
是错误的,它应该是
toEnd:
如果(!$number){..不要减量..}
BTW我认为标签
toEnd;
是错误的,它应该是
toEnd: