草莓 Perl 内存限制?

发布于 2024-12-20 06:16:05 字数 2399 浏览 0 评论 0原文

我正在运行一个 perl 脚本来提取大约 20 个文本文件的列表,并解析它们。由于某种原因,我的进程在列表中途崩溃,并且在调试它时遇到了麻烦。

有人知道 Strawberry Perl 日志文件的位置,以及是否有内置的最大执行时间或内存限制变量(如 PHP 中)?

共有三个文件: 1. cron.php 2.nightly_script.php 3. myscript.pl

它成功执行了 while 循环中的第一个插入语句,但此后不再执行。由于它像 cron 作业一样运行,所以我没有任何输出窗口可供查看。这就是为什么我希望某处有日志,这样如果有语法错误或 mysql 错误我可以在某处看到它。另外,如果我直接在有问题的文件上运行 myscript.pl,它就没有问题。

cron.php

date_default_timezone_set('America/New_York');

/*

min hr dom month dow cmd

hour in 24 hour format, no leading zeros


*/

$jobsQueue = Array();

$jobsQueue[] = Array('10', '0', '*', '*', '*', 'php c:\nightly_script.php');    // These items are order dependent, so run as one script that synchronously executes each command

while(1) {

    $now = time();
    $min = date('i',$now);
    $hr = date('G',$now);

    echo "$hr:$min\n";

    foreach($jobsQueue AS $job) {

        if($job[0] == $min && $job[1] == $hr) {
            system("$job[5]>NULL");
        }

    }

    sleep(60);
}
?>

nightly_script.php

// Process Hand Histories
system('perl myscript.pl');

?>

myscript 片段

while ( ($key, $value) = each(%players) ) {
                print "$key => $value\n";
                if($value > 0)
                {
                    $uname = $key;
                    $uname =~ s/player(.*)(\s*)/$1/;

                    $connect = DBI->connect("DBI:mysql:database=$config_mysql_db;host=$config_mysql_server",$config_mysql_user,$config_mysql_pass,{'RaiseError' => 1});

                    print "\n*****\n$uname\n*****\n";

                    $updateStatement = "INSERT statement";
                    $executeStatement = $connect->prepare($updateStatement);
                    $executeStatement->execute();

                    $updateStatement = "UPDATE command";
                    $executeStatement = $connect->prepare($updateStatement);
                    $executeStatement->execute();

                    delete $players{$key};
                    # Clean up the record set and the database connection
                    $connect->disconnect(); 

                }
                elsif($value <= 0)
                {
                    delete $players{$key};
                }
            }

I'm running a perl script to pull a list of about 20 text files, and parse through them. For some reason my process is bombing partway through the list, and am having trouble debugging it.

Anyone know the location of the Strawberry perl log file, and if there's a builtin max execution time, or memory limit variable like in PHP?

There are three files:
1. cron.php
2. nightly_script.php
3. myscript.pl

It successfully executes the first insert statement in that while loop, but not anymore after that. Since this is running like a cron job I don't have any output window to look at. This is why I was hoping there's a log somewhere, so if there's a syntax error, or a mysql error I can see it somewhere. Also, if I just run myscript.pl on the file in question directly, it works no problem.

cron.php

date_default_timezone_set('America/New_York');

/*

min hr dom month dow cmd

hour in 24 hour format, no leading zeros


*/

$jobsQueue = Array();

$jobsQueue[] = Array('10', '0', '*', '*', '*', 'php c:\nightly_script.php');    // These items are order dependent, so run as one script that synchronously executes each command

while(1) {

    $now = time();
    $min = date('i',$now);
    $hr = date('G',$now);

    echo "$hr:$min\n";

    foreach($jobsQueue AS $job) {

        if($job[0] == $min && $job[1] == $hr) {
            system("$job[5]>NULL");
        }

    }

    sleep(60);
}
?>

nightly_script.php

// Process Hand Histories
system('perl myscript.pl');

?>

myscript snippet

while ( ($key, $value) = each(%players) ) {
                print "$key => $value\n";
                if($value > 0)
                {
                    $uname = $key;
                    $uname =~ s/player(.*)(\s*)/$1/;

                    $connect = DBI->connect("DBI:mysql:database=$config_mysql_db;host=$config_mysql_server",$config_mysql_user,$config_mysql_pass,{'RaiseError' => 1});

                    print "\n*****\n$uname\n*****\n";

                    $updateStatement = "INSERT statement";
                    $executeStatement = $connect->prepare($updateStatement);
                    $executeStatement->execute();

                    $updateStatement = "UPDATE command";
                    $executeStatement = $connect->prepare($updateStatement);
                    $executeStatement->execute();

                    delete $players{$key};
                    # Clean up the record set and the database connection
                    $connect->disconnect(); 

                }
                elsif($value <= 0)
                {
                    delete $players{$key};
                }
            }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山人契 2024-12-27 06:16:05

由于 Perl 没有像 php 这样的日志,因此您可以通过将 Perl 的 stdout 和 stderr 重定向到文件来创建自己的日志文件。尝试通过修改 nightly_script.php 中的系统调用来执行此操作。

system('perl myscript.pl 1>myperllog.txt 2>&1');

或者

system('perl myscript.pl 1>myperllog.txt 2>myperllog.err');

Since perl doesn't have a log like php, you can create your own log file by redirecting perl's stdout and stderr to a file. Try doing this by modifying the system call in nightly_script.php.

system('perl myscript.pl 1>myperllog.txt 2>&1');

or

system('perl myscript.pl 1>myperllog.txt 2>myperllog.err');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文