Skip to content
Related Articles

Related Articles

Perl – Introduction to Debugger

View Discussion
Improve Article
Save Article
  • Last Updated : 10 Jul, 2020

Perl is a general-purpose, high level interpreted and dynamic programming language. Since Perl is a lot similar to other widely used languages syntactically, it is easier to code and learn in Perl. But perfect programs are hard to get in the very first attempt. They have to go through various steps of debugging to fix all errors. These programs may contain some bugs which result in the failure of code execution.

What is a bug?

A bug in software is a flaw, error, fault, or failure that causes the software to fail to perform designated tasks. In simple words, when we make an error during coding, we call it a bug. We measure the impact of a bug on the software by means of two parameters, namely – Severity and Priority.

What is debugging?

The process of finding and removing software errors which result in failure of the software is known as debugging. The debugging phase starts just after receiving a bug report and ends when that bug is removed and the program is working correctly.

How it is done?

The debugging process includes detection and removal of bugs from software programs. The steps of debugging are as follows:

  • Replication of bug: This is the first step in debugging, in which we try to recreate the steps which led to the failure of program by giving the same set of inputs.
  • Understanding the bug: In this step, we try to analyze the reasons which led to the failure of the program. We may have to thoroughly understand the program execution for this. Thus, a debugger helps in this process by providing better mechanisms to understand the program. It inspects the program line-by-line, can pause the program by using breakpoints, uses watch to keep track of variables, registers, etc.
  • Locating the bug: After we know the incorrect behavior, we aim to find the portion of source code that produces this error. This activity is known as locating the bug. To do this, we may have to inspect the source code, watch variable changes, etc.
  • Fixing the bug and re-testing of program: This is the final step of debugging, where we fix the bug in the software program. We then have to re-test the program and see if the bug is removed and all corrections are in place. During this step, it is possible that some other portions of the program may get affected too. Hence an impact analysis may have to be performed to identify the affected portions and re-test them. This process is known as regression testing.

Entering and Exiting the Debugger

To enter into debugger, we can type the following command :

perl -d program_name

Exiting the Debugger
To exit from the debugger we can press q or use:

Ctrl+D or Ctrl+Z
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!