Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling executing a subroutine in perl in the DEBUG mode

Is it possible to disable execution of a specific subroutine, when we are executing the script in DEBUG mode?.

Supoose, sub tryme is being called and takes quite a long time to execute, I would like to disable/skip executing the subroutine.

  • One option available is to comment the call - editing the script is not recommended
  • Modify a variable which is checked in tryme() - the sub routine does not have that facility
  • Hence, can we use any of the DEBUG options to disabling executing the subroutine

Thanks,

like image 531
user2609370 Avatar asked May 24 '26 09:05

user2609370


1 Answers

You can set a global Variable or a Command-Line Variable to set (for example) $debug = 1. Then you could specifiy your sub-calls like that:

_long_function() unless $debug == 1;

or

unless ($debug) {
    ...
}