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
- Perl | Breakpoints of a Debugger
- Perl | Displaying Variable Values with a Debugger
- Perl | Line Action Commands in a Debugger
- Perl - Listing your Program with a Debugger
- Perl | Basic Syntax of a Perl Program
- Perl Tutorial - Learn Perl With Examples
- Introduction to Perl
- Perl | File Handling Introduction
- Perl | split() Function
- Perl | chomp() Function
- Perl | Backtracking in Regular Expression
- Perl | Searching in a File using regex
- Perl | Operators | Set - 1
- Perl | lt operator
- Perl | chop() Function
- Perl | rename() Function
- Perl | Subroutines or Functions
- Perl | Decision Making (if, if-else, Nested–if, if-elsif ladder, unless, unless-else, unless-elsif)
- Perl | Scalars
- Perl | Loops (for, foreach, while, do...while, until, Nested loops)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.