Beginners Perl language, the first contact is not its syntax, but its debugging method, was due to a Perl script generated HTML page does not display properly, let me find out the cause of the problem, and then fix, was the first time to contact Perl, completely without any understanding, By virtue of learning a few words in the teriminal can be used in the debug command, quickly solve the problem, so, it is easy to debug Perl is very simple, as long as the use of the following sentences:
perl-d filename
This is a debug command that goes into Perl.
The following words will appear on the screen:
Enter h or ' h ' for help, or ' man perldebug ' for more help.
Main::(Filename:linenumber)
Linenumber:content;
Db<1>
FileName is the name of the file being debugged, LineNumber displays the line number of the current debug statement, and the content is the currently debugged statement,db<1> followed by a small black square cursor
1. You can enter n at this time, equivalent to F10 in Visual Studio, to the next sentence of debugging
2. If you want to run directly to the nth line statement, you can set a breakpoint at line N: B N (replace N with the line where you want to set the breakpoint)
Number), enter the breakpoint after the setting is successful, you can input l to see all the breakpoints set, do not want to see or can directly enter C,
Enter and run directly to the statement where the breakpoint is set.
3, want to delete the breakpoint can be B N (replace N with the line number that needs to set the breakpoint), enter after the line at the breakpoint is deleted,
You can also delete all breakpoints by B *
4, want to see the value of the variable, through the print variable name can be viewed
5, you can also directly change the value of the variables in the debug script by assigning values to the variables, such as direct input: $debug = 0, so
The value of $debug is assigned to 0.
6, exit debugging, as long as the input Q can
Other debugging methods can be learned by reading the Help file, enter H, just a few small commands, you can implement the Perl script
debugging, isn't it simple?
Perl-Related Simple debugging tips