gpt4 book ai didi

perl - Perl 脚本如何检测它是否在 Komodo IDE 中运行?

转载 作者:行者123 更新时间:2023-12-01 01:37:09 25 4
gpt4 key购买 nike

我发现的一种方法是通过检查 defined($DB::single) 并假设 Komodo 处于事件状态,如果定义了 $DB::single 来检查 Perl 调试器是否“加载”。

但这也可能意味着脚本在“独立”调试器下以 perl -d 的身份合法运行。

#!/usr/local/ActivePerl-5.10/bin/perl
use strict;
use warnings;
use feature qw/say switch/;

# detect debugger ..
SayDebugerStatus();
sub SayDebugerStatus {
print "Debugger ";
given ($DB::single) {
when (undef) {
say "not loaded.";
}
when (0) {
say "loaded but inactive";
}
default {
say "loaded and active";
}
}
return defined($DB::single) ? 1:0;
}

扎科维亚的建议导致:
if ( grep( /.*Komodo\ IDE\.app/g,  values %INC) ){
say "Komodo is running"
} else {
say "Komodo is not running"
};

但是还有其他方法吗?

更新 今天我的 isKomodo() 例程失败了。一些调查表明,IT 将我的全局路径设置从“长”名称更改为“短”名称(这是在 Windows 下).. %INC 哈希中不再有“KOMODO”字符串..

我正在寻找替代品。

最佳答案

当您在 Komodo 下启动脚本时,您的 %INC 包含什么?很有可能会加载一些 Komodo 特定的模块。
最好用以下方式打印其内容:

use Data::Dumper;
print Dumper \%INC;

关于perl - Perl 脚本如何检测它是否在 Komodo IDE 中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1195175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com