package Test::Utils::Dump::Load; use v5.10; use strict; use warnings; use Exporter 'import'; our @EXPORT = qw(d d0 d1 dd di); my $debug = $ENV{MYMOD_DEBUG_LEVEL}; sub d { _load_and_call('d', @_) if $debug } sub d0 { _load_and_call('d0', @_) if $debug } sub d1 { _load_and_call('d1', @_) if $debug } sub dd { _load_and_call('dd', @_) if $debug } sub di { _load_and_call('di', @_) if $debug } sub _load_and_call { my $sub_name = shift; state $imported = 0; if (!$imported) { require Test::Utils::Dump; Test::Utils::Dump->import(qw(d d0 d1 dd di)); $imported = 1; } no strict 'refs'; ## no critic &{"Test::Utils::Dump::$sub_name"}(@_); } 1; #### use Test::Utils::Dump::Load;