are you running under the perl debugger ?

Marc Espie <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
The following snippet:

can be used to determine if I am running under perl -d.

I'm wondering if there's something cleaner.

#! /usr/bin/perl

use v5.36;

my $db;
eval { no strict 'subs'; 
	$db = DB->can(DB); };

if ($db) {
	say "debugguer";
}


The reason I'm asking is because pkg_add is a giant try {} catch ();
(okay the actual code is a lexical eval {} with if ($@) test)

I have a -Ddebug switch that can turn that off, which is very useful when
debugging -- turns out, the perl debugger is not so great at entering evals.


I have several questions: am I missing something ?

If not, I would like to use something like tne above in order to, by default,
remove the eval {}; if ($@)... block in case the code detects it runs under
the debugguer.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.