views:

189

answers:

1

One way I found is to check if the Perl Debugger is "loaded" by checking for defined($DB::single) and assuming Komodo is active, if $DB::single is defined..

But this might also mean the script is legitimately running as perl -d under the "standalone" debugger.

#!/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;
}


zakovyrya's suggestion leads to:

if ( grep( /.*Komodo\ IDE\.app/g,  values %INC) ){
    say "Komodo is running"
} else {
   say "Komodo is not running"
};

But is there another way?


UPDATE today my isKomodo() routine failed. Some investigation showed, that IT changed my global path settings from "long" to "short" names (this is under Windows) .. there nolonger is a "KOMODO" string in the %INC hash..

I'm looking for a replacement.

+2  A: 

What does your %INC contain when you launch script under Komodo? There is a good chance that some Komodo-specific modules are loaded. It's better to print its content with:

use Data::Dumper;
print Dumper \%INC;
zakovyrya
+1 **that works**, see my edited question ... but since "%INC" is external (based on environment) I still hope there might be another way to detect Komodo.
lexu
You will need something external. Komodo could hardly influence something internal.
innaM
as I showed above, it already loads the debugger without my doing (kind-of) .. it might load something else that is identifiable..
lexu