Perl文件里如何调用另一个文件里边的命令
我现在需要做一个小工具,在一个Perl文件里想调用另一个Perl里的命令,就是在这段程序里:subbtn_run_Click{$main->btn_run->Disabl...
我现在需要做一个小工具,在一个Perl文件里想调用另一个Perl里的命令,
就是在这段程序里:
sub btn_run_Click {
$main->btn_run->Disable(); # disable me (bu_run)
my $str = undef;
$str = "avrdude.exe -p m8 -c stk200 -P lpt1 -U flash:w:\"C:\\TM_burn_file\\main.hex\":i -U eeprom:w:\"C:\\TM_burn_file\\main.eep\":a -U lfuse:w:0x84:m -U hfuse:w:0xD9:m 2>&1";
#$str = $main->inputwin->GetLine(0);
$str = $str . " 2>&1";
my $flag = 0; # burnning status
if (defined($str))
{
# execute DOS command
my @result = qx($str);
foreach (@result )
{
$main->resultwin->Append($_);
#$main->resultwin->Append("\r\n");
if ($_ =~ /initialization failed, rc=-1/)
{
$flag |= 0x1;
}
if ($_ =~ /failed/)
{
$flag |= 0x2;
}
}
}
# AVR device not responding
if ($flag & 0x1)
{
$main->MessageBox(
"请正确编程线缆\r\nCheck Programmer Cable",
"Check",
MB_ICONINFORMATION | MB_OK,
);
}
# failed
if ($flag & 0x2)
{
$main->MessageBox(
"烧写失败\r\nBurn Failed.",
"Failed",
MB_ICONINFORMATION | MB_OK,
);
}
# successful
if ($flag == 0)
{
$main->MessageBox(
"烧写成功\r\nBurn Successfully.",
"Success",
MB_ICONINFORMATION | MB_OK,
);
}
$main->btn_run->Enable(); # enalbe me (but_run)
} 展开
就是在这段程序里:
sub btn_run_Click {
$main->btn_run->Disable(); # disable me (bu_run)
my $str = undef;
$str = "avrdude.exe -p m8 -c stk200 -P lpt1 -U flash:w:\"C:\\TM_burn_file\\main.hex\":i -U eeprom:w:\"C:\\TM_burn_file\\main.eep\":a -U lfuse:w:0x84:m -U hfuse:w:0xD9:m 2>&1";
#$str = $main->inputwin->GetLine(0);
$str = $str . " 2>&1";
my $flag = 0; # burnning status
if (defined($str))
{
# execute DOS command
my @result = qx($str);
foreach (@result )
{
$main->resultwin->Append($_);
#$main->resultwin->Append("\r\n");
if ($_ =~ /initialization failed, rc=-1/)
{
$flag |= 0x1;
}
if ($_ =~ /failed/)
{
$flag |= 0x2;
}
}
}
# AVR device not responding
if ($flag & 0x1)
{
$main->MessageBox(
"请正确编程线缆\r\nCheck Programmer Cable",
"Check",
MB_ICONINFORMATION | MB_OK,
);
}
# failed
if ($flag & 0x2)
{
$main->MessageBox(
"烧写失败\r\nBurn Failed.",
"Failed",
MB_ICONINFORMATION | MB_OK,
);
}
# successful
if ($flag == 0)
{
$main->MessageBox(
"烧写成功\r\nBurn Successfully.",
"Success",
MB_ICONINFORMATION | MB_OK,
);
}
$main->btn_run->Enable(); # enalbe me (but_run)
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询