Index | Thread | Search

From:
Marc Espie <marc.espie.openbsd@gmail.com>
Subject:
are you running under the perl debugger ?
To:
tech@openbsd.org
Cc:
afresh1@openbsd.org
Date:
Tue, 23 Jun 2026 18:08:01 +0200

Download raw body.

Thread
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.