为什么Windows为编译的Perl脚本生成了大量进程?

时间:2016-06-06 09:32:19

标签: windows perl

由于解决了我的ISP问题,我编写了这个脚本(称为SpeedTest.pl)来记录互联网速度。 它工作得很好,但就好像我使用Perl解释器(如果我双击脚本)。我想编译它以生成一个独立的可执行文件,以便在没有安装Perl的情况下在另一台PC上运行。

好吧,我尝试使用pp和Perl2Exe,但是当我启动SpeedTest.exe时,我在任务管理器中看到很多名为“SpeedTest.exe”的进程。如果我不阻止所有这些过程,PC操作系统将崩溃(弹出窗口说:“内存无法写入,等等等等。)

有什么想法吗?

这是剧本:

#!/usr/local/bin/perl
use strict;
use warnings;
use App::SpeedTest;


my($day, $month_temp, $year_temp)=(localtime)[3,4,5];
my $year = $year_temp+1900;
my $month = $month_temp+1;
my $date = "0"."$day"."-"."0"."$month"."-"."$year";
my $filename = "Speed Test - "."$date".".csv";


if (-e $filename) {
     goto SPEEDTEST; 
     } else {
     goto CREATEFILE;
                  }


CREATEFILE:

open(FILE, '>', $filename);
print FILE "Date".";"."Time".";"."Download [Mbit/s]".";"."Upload [Mbit/s]".";"."\n";
close FILE;
goto SPEEDTEST; 



SPEEDTEST:


my $download = qx(speedtest -Q -C --no-upload);
my $upload = qx(speedtest -Q -C --no-download);

my @download_chars = split("", $download);
my @upload_chars = split("", $upload);
my $time = "$download_chars[12]"."$download_chars[13]"."$download_chars[14]"."$download_chars[15]"."$download_chars[16]";
my $download_speed = "$download_chars[49]"."$download_chars[50]"."$download_chars[51]"."$download_chars[52]"."$download_chars[53]";
my $upload_speed = "$upload_chars[49]"."$upload_chars[50]"."$upload_chars[51]"."$upload_chars[52]"."$upload_chars[53]";
my $output = "$date".";"."$time".";"."$download_speed".";"."$upload_speed".";";

open(FILE, '>>', $filename);
print FILE $output."\n";
close FILE;

sleep 300;

my($day_check, $month_temp_check, $year_temp_check)=(localtime)[3,4,5];
my $year_check = $year_temp_check+1900;
my $month_check = $month_temp_check+1;
my $date_check = "0"."$day_check"."-"."0"."$month_check"."-"."$year_check";
my $filename_check = "Speed Test - "."$date_check".".csv";

if ($filename = $filename_check) {
goto SPEEDTEST; 
} else {
$filename = $filename_check;
goto CREATEFILE;
                                 }

1 个答案:

答案 0 :(得分:0)

嗯,Steffen通过评论的方式回答了这个问题,但这里是答案。只需将Perl编译成一个与Perl脚本调用的名称不同的EXE,例如:

Configuration.driver.Navigate().GoToUrl("http://example.com/"); 汇编为speedtest.pl,调用myspeedtest.exe