File: perldebug.html

package info (click to toggle)
perl-doc-html 5.26.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 39,400 kB
  • sloc: xml: 36; makefile: 7
file content (1580 lines) | stat: -rw-r--r-- 76,737 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>perldebug - perldoc.perl.org</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta http-equiv="Content-Language" content="en-gb">
  <link rel="search" type="application/opensearchdescription+xml" title="Search perldoc.perl.org" href="/static/search.xml"/>
  <link href="static/css-20100830.css" rel="stylesheet" rev="stylesheet" type="text/css" media="screen">
  <link href="static/exploreperl.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>

<body onLoad="perldoc.startup();" onPageShow="if (event.persisted) perldoc.startup();">
    <div id="page">
      
      <div id="header">
	<div id="homepage_link">
	  <a href="index.html"></a>
	</div>
	<div id="strapline">
	  Perl Programming Documentation
	</div>
	<div id="download_link" class="download">
	  <a href="http://www.perl.org/get.html">Download Perl</a>
	</div>
	<div id="explore_link" class="download">
	  <a id="explore_anchor" href="#">Explore</a>
	</div>
      </div>
      
      <div id="body">
        <div id="left_column">
          <div class="side_group">
            
	    <div class="side_panel doc_panel">
              <p>Manual</p>
              <ul>
                <li><a href="index-overview.html">Overview</a>
                <li><a href="index-tutorials.html">Tutorials</a>
                <li><a href="index-faq.html">FAQs</a>
                <li><a href="index-history.html">History / Changes</a>
                <li><a href="index-licence.html">License</a>
              </ul>
            </div>
            <div class="side_panel doc_panel">
              <p>Reference</p>
              <ul>
                <li><a href="index-language.html">Language</a>
                <li><a href="index-functions.html">Functions</a>
                <li><a href="perlop.html">Operators</a>
                <li><a href="perlvar.html">Special Variables</a>
                <li><a href="index-pragmas.html">Pragmas</a>
                <li><a href="index-utilities.html">Utilities</a>
                <li><a href="index-internals.html">Internals</a>
                <li><a href="index-platforms.html">Platform Specific</a>
              </ul>
            </div>
            <div class="side_panel doc_panel">
              <p>Modules</p>
              <ul>
		<li>
		
                
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		
                  
		
		
                    <a href="index-modules-A.html">A</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-B.html">B</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-C.html">C</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-D.html">D</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-E.html">E</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-F.html">F</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-G.html">G</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-H.html">H</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-I.html">I</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-L.html">L</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-M.html">M</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-N.html">N</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-O.html">O</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-P.html">P</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-S.html">S</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-T.html">T</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-U.html">U</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-X.html">X</a>
                    
                
              </ul>
            </div>
            
	      <div class="side_panel doc_panel">
		<p>Tools</p>
		<ul>
		  <li><a href="preferences.html">Preferences</a>
		</ul>
	      </div>
            
          </div>
        </div>
        <div id="centre_column">
          <div id="content_header">
            <div id="title_bar">
              <div id="page_name">
                <h1>perldebug</h1>
              </div>
              <div id="perl_version">
                Perl 5 version 26.0 documentation
              </div>
              <div class="page_links" id="page_links_top">
                <a href="#" onClick="toolbar.goToTop();return false;">Go to top</a>
		
              </div>
	      <div class="page_links" id="page_links_bottom">
		
                  <a href="#" id="page_index_toggle">Show page index</a> &bull;
		
                <a href="#" id="recent_pages_toggle">Show recent pages</a>		
	      </div>
	      <div id="search_form">
		<form action="search.html" method="GET" id="search">
		  <input type="text" name="q" id="search_box" alt="Search">
		</form>
	      </div>
            </div>
            <div id="breadcrumbs">
                
    <a href="index.html">Home</a> &gt;
    
      
        <a href="index-language.html">Language reference</a> &gt;
      
    
    perldebug
  

            </div>
          </div>
          <div id="content_body">
	    <!--[if lt IE 7]>
 <div class="noscript">
   <p>
     <strong>It looks like you're using Internet Explorer 6. This is a very old
     browser which does not offer full support for modern websites.</strong>
   </p>
   <p>
     Unfortunately this means that this website will not work on
     your computer.
   </p>
   <p>
     Don't miss out though! To view the site (and get a better experience from
     many other websites), simply upgrade to
     <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet
Explorer 8</a>
     or download an alternative browser such as
     <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>,
     <a href="http://www.apple.com/safari/download/">Safari</a>, or
     <a href="http://www.google.co.uk/chrome">Google Chrome</a>.
   </p>
   <p>
     All of these browsers are free. If you're using a PC at work, you may
     need to contact your IT administrator.
   </p>
 </div>
<![endif]-->
	    <noscript>
	      <div class="noscript">
	      <p>
                <strong>Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled,
	        or are running a non-JavaScript capable web browser.</strong>
	      </p>
	      <p>
		To get the best experience, please enable JavaScript or download a modern web browser such as <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet Explorer 8</a>, <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>, <a href="http://www.apple.com/safari/download/">Safari</a>, or <a href="http://www.google.co.uk/chrome">Google Chrome</a>.
              </p>
	      </div>
	    </noscript>

	    <div id="recent_pages" class="hud_container">
	      <div id="recent_pages_header" class="hud_header">
		<div id="recent_pages_close" class="hud_close"><a href="#" onClick="recentPages.hide();return false;"></a></div>
		<div id="recent_pages_title" class="hud_title"><span class="hud_span_top">Recently read</span></div>
		<div id="recent_pages_topright" class="hud_topright"></div>
	      </div>
	      <div id="recent_pages_content" class="hud_content">
	      </div>
	      <div id="recent_pages_footer" class="hud_footer">
		<div id="recent_pages_bottomleft" class="hud_bottomleft"></div>
		<div id="recent_pages_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
		<div id="recent_pages_resize" class="hud_resize"></div>
	      </div>
	    </div>
  
	    <div id="from_search"></div>
            <h1>perldebug</h1>


  <!--    -->
<ul><li><a href="#NAME">NAME
 </a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#The-Perl-Debugger">The Perl Debugger</a><ul><li><a href="#Calling-the-Debugger">Calling the Debugger</a><li><a href="#Debugger-Commands">Debugger Commands</a><li><a href="#Configurable-Options">Configurable Options</a><li><a href="#Debugger-Input%2fOutput">Debugger Input/Output</a><li><a href="#Debugging-Compile-Time-Statements">Debugging Compile-Time Statements</a><li><a href="#Debugger-Customization">Debugger Customization</a><li><a href="#Readline-Support-%2f-History-in-the-Debugger">Readline Support / History in the Debugger</a><li><a href="#Editor-Support-for-Debugging">Editor Support for Debugging</a><li><a href="#The-Perl-Profiler">The Perl Profiler
  </a></ul><li><a href="#Debugging-Regular-Expressions">Debugging Regular Expressions

 </a><li><a href="#Debugging-Memory-Usage">Debugging Memory Usage
</a><li><a href="#SEE-ALSO">SEE ALSO</a><li><a href="#BUGS">BUGS</a></ul><a name="NAME"></a><h1>NAME
 </h1>
<p>perldebug - Perl debugging</p>
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
<p>First of all, have you tried using <a href="strict.html">use strict; </a> and
<a href="warnings.html">use warnings; </a>?</p>
<p>If you're new to the Perl debugger, you may prefer to read
<a href="perldebtut.html">perldebtut</a>, which is a tutorial introduction to the debugger.</p>
<a name="The-Perl-Debugger"></a><h1>The Perl Debugger</h1>
<p>If you invoke Perl with the <b>-d</b> switch, your script runs under the
Perl source debugger.  This works like an interactive Perl
environment, prompting for debugger commands that let you examine
source code, set breakpoints, get stack backtraces, change the values of
variables, etc.  This is so convenient that you often fire up
the debugger all by itself just to test out Perl constructs
interactively to see what they do.  For example:
</p>
<pre class="verbatim"><ol><li>    <span class="i">$ perl</span> -<span class="w">d</span> -e <span class="n">42</span></li></ol></pre><p>In Perl, the debugger is not a separate program the way it usually is in the
typical compiled environment.  Instead, the <b>-d</b> flag tells the compiler
to insert source information into the parse trees it's about to hand off
to the interpreter.  That means your code must first compile correctly
for the debugger to work on it.  Then when the interpreter starts up, it
preloads a special Perl library file containing the debugger.</p>
<p>The program will halt <i>right before</i> the first run-time executable
statement (but see below regarding compile-time statements) and ask you
to enter a debugger command.  Contrary to popular expectations, whenever
the debugger halts and shows you a line of code, it always displays the
line it's <i>about</i> to execute, rather than the one it has just executed.</p>
<p>Any command not recognized by the debugger is directly executed
(<code class="inline"><a class="l_k" href="functions/eval.html">eval</a></code>'d) as Perl code in the current package.  (The debugger
uses the DB package for keeping its own state information.)</p>
<p>Note that the said <code class="inline"><a class="l_k" href="functions/eval.html">eval</a></code> is bound by an implicit scope. As a
result any newly introduced lexical variable or any modified
capture buffer content is lost after the eval. The debugger is a
nice environment to learn Perl, but if you interactively experiment using
material which should be in the same scope, stuff it in one line.</p>
<p>For any text entered at the debugger prompt, leading and trailing whitespace
is first stripped before further processing.  If a debugger command
coincides with some function in your own program, merely precede the
function with something that doesn't look like a debugger command, such
as a leading <code class="inline"><span class="sc">;</span></code>
 or perhaps a <code class="inline">+</code>
, or by wrapping it with parentheses
or braces.</p>
<a name="Calling-the-Debugger"></a><h2>Calling the Debugger</h2>
<p>There are several ways to call the debugger:</p>
<ul>
<li><a name="perl--d-program_name"></a><b>perl -d program_name</b>
<p>On the given program identified by <code class="inline"><span class="w">program_name</span></code>
.</p>
</li>
<li><a name="perl--d--e-0"></a><b>perl -d -e 0</b>
<p>Interactively supply an arbitrary <code class="inline"><span class="w">expression</span></code>
 using <code class="inline">-e</code>
.</p>
</li>
<li><a name="perl--d%3aptkdb-program_name"></a><b>perl -d:ptkdb program_name</b>
<p>Debug a given program via the <code class="inline"><span class="w">Devel::ptkdb</span></code>
 GUI.</p>
</li>
<li><a name="perl--dt-threaded_program_name"></a><b>perl -dt threaded_program_name</b>
<p>Debug a given program using threads (experimental).</p>
</li>
</ul>
<a name="Debugger-Commands"></a><h2>Debugger Commands</h2>
<p>The interactive debugger understands the following commands:</p>
<ul>
<li><a name="h"></a><b>h
</b>
<p>Prints out a summary help message</p>
</li>
<li><a name="h-%5bcommand%5d"></a><b>h [command]</b>
<p>Prints out a help message for the given debugger command.</p>
</li>
<li><a name="h-h"></a><b>h h</b>
<p>The special argument of <code class="inline"><span class="w">h</span> <span class="w">h</span></code>
 produces the entire help page, which is quite long.</p>
<p>If the output of the <code class="inline"><span class="w">h</span> <span class="w">h</span></code>
 command (or any command, for that matter) scrolls
past your screen, precede the command with a leading pipe symbol so
that it's run through your pager, as in</p>
<pre class="verbatim"><ol><li>    DB&gt; |h h</li></ol></pre><p>You may change the pager which is used via <code class="inline"><span class="w">o</span> <span class="w">pager</span>=...</code>
 command.</p>
</li>
<li><a name="p-expr"></a><b>p expr
</b>
<p>Same as <code class="inline"><a class="l_k" href="functions/print.html">print</a> <span class="s">{</span><span class="i">$DB::OUT</span><span class="s">}</span> <span class="w">expr</span></code>
 in the current package.  In particular,
because this is just Perl's own <code class="inline"><a class="l_k" href="functions/print.html">print</a></code> function, this means that nested
data structures and objects are not dumped, unlike with the <code class="inline"><span class="w">x</span></code>
 command.</p>
<p>The <code class="inline"><span class="w">DB::OUT</span></code>
 filehandle is opened to <i>/dev/tty</i>, regardless of
where STDOUT may be redirected to.</p>
</li>
<li><a name="x-%5bmaxdepth%5d-expr"></a><b>x [maxdepth] expr
</b>
<p>Evaluates its expression in list context and dumps out the result in a
pretty-printed fashion.  Nested data structures are printed out
recursively, unlike the real <code class="inline"><a class="l_k" href="functions/print.html">print</a></code> function in Perl.  When dumping
hashes, you'll probably prefer 'x \%h' rather than 'x %h'.
See <a href="Dumpvalue.html">Dumpvalue</a> if you'd like to do this yourself.</p>
<p>The output format is governed by multiple options described under
<a href="#Configurable-Options">Configurable Options</a>.</p>
<p>If the <code class="inline"><span class="w">maxdepth</span></code>
 is included, it must be a numeral <i>N</i>; the value is
dumped only <i>N</i> levels deep, as if the <code class="inline"><span class="w">dumpDepth</span></code>
 option had been
temporarily set to <i>N</i>.</p>
</li>
<li><a name="V-%5bpkg-%5bvars%5d%5d"></a><b>V [pkg [vars]]
</b>
<p>Display all (or some) variables in package (defaulting to <code class="inline"><span class="w">main</span></code>
)
using a data pretty-printer (hashes show their keys and values so
you see what's what, control characters are made printable, etc.).
Make sure you don't put the type specifier (like <code class="inline"><span class="i">$</span></code>
) there, just
the symbol names, like this:</p>
<pre class="verbatim"><ol><li>    <span class="w">V</span> <span class="w">DB</span> <span class="w">filename</span> <span class="w">line</span></li></ol></pre><p>Use <code class="inline">~<span class="w">pattern</span></code>
 and <code class="inline">!<span class="w">pattern</span></code>
 for positive and negative regexes.</p>
<p>This is similar to calling the <code class="inline"><span class="w">x</span></code>
 command on each applicable var.</p>
</li>
<li><a name="X-%5bvars%5d"></a><b>X [vars]
</b>
<p>Same as <code class="inline"><span class="w">V</span> <span class="w">currentpackage</span> <span class="s">[</span><span class="w">vars</span><span class="s">]</span></code>
.</p>
</li>
<li><a name="y-%5blevel-%5bvars%5d%5d"></a><b>y [level [vars]]
</b>
<p>Display all (or some) lexical variables (mnemonic: <code class="inline"><span class="w">mY</span></code>
 variables)
in the current scope or <i>level</i> scopes higher.  You can limit the
variables that you see with <i>vars</i> which works exactly as it does
for the <code class="inline"><span class="w">V</span></code>
 and <code class="inline"><span class="w">X</span></code>
 commands.  Requires the <code class="inline"><span class="w">PadWalker</span></code>
 module
version 0.08 or higher; will warn if this isn't installed.  Output
is pretty-printed in the same style as for <code class="inline"><span class="w">V</span></code>
 and the format is
controlled by the same options.</p>
</li>
<li><a name="T"></a><b>T
  </b>
<p>Produce a stack backtrace.  See below for details on its output.</p>
</li>
<li><a name="s-%5bexpr%5d"></a><b>s [expr]
 </b>
<p>Single step.  Executes until the beginning of another
statement, descending into subroutine calls.  If an expression is
supplied that includes function calls, it too will be single-stepped.</p>
</li>
<li><a name="n-%5bexpr%5d"></a><b>n [expr]
</b>
<p>Next.  Executes over subroutine calls, until the beginning
of the next statement.  If an expression is supplied that includes
function calls, those functions will be executed with stops before
each statement.</p>
</li>
<li><a name="r"></a><b>r
</b>
<p>Continue until the return from the current subroutine.
Dump the return value if the <code class="inline"><span class="w">PrintRet</span></code>
 option is set (default).</p>
</li>
<li><a name="%3cCR%3e"></a><b>&lt;CR&gt;</b>
<p>Repeat last <code class="inline"><span class="w">n</span></code>
 or <code class="inline"><a class="l_k" href="functions/s.html">s</a></code> command.</p>
</li>
<li><a name="c-%5bline%7csub%5d"></a><b>c [line|sub]
</b>
<p>Continue, optionally inserting a one-time-only breakpoint
at the specified line or subroutine.</p>
</li>
<li><a name="l"></a><b>l
</b>
<p>List next window of lines.</p>
</li>
<li><a name="l-min%2bincr"></a><b>l min+incr</b>
<p>List <code class="inline"><span class="w">incr</span>+<span class="n">1</span></code>
 lines starting at <code class="inline"><span class="w">min</span></code>
.</p>
</li>
<li><a name="l-min-max"></a><b>l min-max</b>
<p>List lines <code class="inline"><span class="w">min</span></code>
 through <code class="inline"><span class="w">max</span></code>
.  <code class="inline"><span class="w">l</span> -</code>
 is synonymous to <code class="inline">-</code>
.</p>
</li>
<li><a name="l-line"></a><b>l line</b>
<p>List a single line.</p>
</li>
<li><a name="l-subname"></a><b>l subname</b>
<p>List first window of lines from subroutine.  <i>subname</i> may
be a variable that contains a code reference.</p>
</li>
<li><a name="-"></a><b>-
</b>
<p>List previous window of lines.</p>
</li>
<li><a name="v-%5bline%5d"></a><b>v [line]
</b>
<p>View a few lines of code around the current line.</p>
</li>
<li><a name="."></a><b>.
</b>
<p>Return the internal debugger pointer to the line last
executed, and print out that line.</p>
</li>
<li><a name="f-filename"></a><b>f filename
</b>
<p>Switch to viewing a different file or <code class="inline"><a class="l_k" href="functions/eval.html">eval</a></code> statement.  If <i>filename</i>
is not a full pathname found in the values of %INC, it is considered
a regex.</p>
<p><code class="inline"><a class="l_k" href="functions/eval.html">eval</a></code>ed strings (when accessible) are considered to be filenames:
<code class="inline"><span class="w">f</span> <span class="s">(</span><a class="l_k" href="functions/eval.html">eval</a> <span class="n">7</span><span class="s">)</span></code>
 and <code class="inline"><span class="w">f</span> <a class="l_k" href="functions/eval.html">eval</a> <span class="n">7</span>\<span class="w">b</span></code>
 access the body of the 7th <code class="inline"><a class="l_k" href="functions/eval.html">eval</a></code>ed string
(in the order of execution).  The bodies of the currently executed <code class="inline"><a class="l_k" href="functions/eval.html">eval</a></code>
and of <code class="inline"><a class="l_k" href="functions/eval.html">eval</a></code>ed strings that define subroutines are saved and thus
accessible.</p>
</li>
<li><a name="%2fpattern%2f"></a><b>/pattern/</b>
<p>Search forwards for pattern (a Perl regex); final / is optional.
The search is case-insensitive by default.</p>
</li>
<li><a name="%3fpattern%3f"></a><b>?pattern?</b>
<p>Search backwards for pattern; final ? is optional.
The search is case-insensitive by default.</p>
</li>
<li><a name="L-%5babw%5d"></a><b>L [abw]
</b>
<p>List (default all) actions, breakpoints and watch expressions</p>
</li>
<li><a name="S-%5b%5b!%5dregex%5d"></a><b>S [[!]regex]
</b>
<p>List subroutine names [not] matching the regex.</p>
</li>
<li><a name="t-%5bn%5d"></a><b>t [n]
</b>
<p>Toggle trace mode (see also the <code class="inline"><span class="w">AutoTrace</span></code>
 option).
Optional argument is the maximum number of levels to trace below
the current one; anything deeper than that will be silent.</p>
</li>
<li><a name="t-%5bn%5d-expr"></a><b>t [n] expr
</b>
<p>Trace through execution of <code class="inline"><span class="w">expr</span></code>
.
Optional first argument is the maximum number of levels to trace below
the current one; anything deeper than that will be silent.
See <a href="perldebguts.html#Frame-Listing-Output-Examples">Frame Listing Output Examples in perldebguts</a> for examples.</p>
</li>
<li><a name="b"></a><b>b

</b>
<p>Sets breakpoint on current line</p>
</li>
<li><a name="b-%5bline%5d-%5bcondition%5d"></a><b>b [line] [condition]

</b>
<p>Set a breakpoint before the given line.  If a condition
is specified, it's evaluated each time the statement is reached: a
breakpoint is taken only if the condition is true.  Breakpoints may
only be set on lines that begin an executable statement.  Conditions
don't use <code class="inline">if</code>
:</p>
<pre class="verbatim"><ol><li>    b 237 $x &gt; 30</li><li>    b 237 ++$count237 &lt; 11</li><li>    b 33 /pattern/i</li></ol></pre><p>If the line number is <code class="inline">.</code>, sets a breakpoint on the current line:</p>
<pre class="verbatim"><ol><li>    <span class="w">b</span> . <span class="i">$n</span> &gt; <span class="n">100</span></li></ol></pre></li>
<li><a name="b-%5bfile%5d%3a%5bline%5d-%5bcondition%5d"></a><b>b [file]:[line] [condition]

</b>
<p>Set a breakpoint before the given line in a (possibly different) file.  If a
condition is specified, it's evaluated each time the statement is reached: a
breakpoint is taken only if the condition is true.  Breakpoints may only be set
on lines that begin an executable statement.  Conditions don't use <code class="inline">if</code>
:</p>
<pre class="verbatim"><ol><li>    <span class="w">b</span> <span class="w">lib</span>/<span class="w">MyModule</span>.<span class="w">pm</span><span class="co">:</span><span class="n">237</span> <span class="i">$x</span> &gt; <span class="n">30</span></li><li>    <span class="w">b</span> /<span class="w">usr</span>/<span class="w">lib</span>/<span class="w">perl5</span>/<span class="w">site_perl</span>/<span class="w">CGI</span>.<span class="w">pm</span><span class="co">:</span><span class="n">100</span> ++<span class="i">$count100</span> &lt; <span class="n">11</span></li></ol></pre></li>
<li><a name="b-subname-%5bcondition%5d"></a><b>b subname [condition]

</b>
<p>Set a breakpoint before the first line of the named subroutine.  <i>subname</i> may
be a variable containing a code reference (in this case <i>condition</i>
is not supported).</p>
</li>
<li><a name="b-postpone-subname-%5bcondition%5d"></a><b>b postpone subname [condition]

</b>
<p>Set a breakpoint at first line of subroutine after it is compiled.</p>
</li>
<li><a name="b-load-filename"></a><b>b load filename

</b>
<p>Set a breakpoint before the first executed line of the <i>filename</i>,
which should be a full pathname found amongst the %INC values.</p>
</li>
<li><a name="b-compile-subname"></a><b>b compile subname

</b>
<p>Sets a breakpoint before the first statement executed after the specified
subroutine is compiled.</p>
</li>
<li><a name="B-line"></a><b>B line

</b>
<p>Delete a breakpoint from the specified <i>line</i>.</p>
</li>
<li><a name="B-*"></a><b>B *

</b>
<p>Delete all installed breakpoints.</p>
</li>
<li><a name="disable-%5bfile%5d%3a%5bline%5d"></a><b>disable [file]:[line]


</b>
<p>Disable the breakpoint so it won't stop the execution of the program. 
Breakpoints are enabled by default and can be re-enabled using the <code class="inline"><span class="w">enable</span></code>

command.</p>
</li>
<li><a name="disable-%5bline%5d"></a><b>disable [line]


</b>
<p>Disable the breakpoint so it won't stop the execution of the program. 
Breakpoints are enabled by default and can be re-enabled using the <code class="inline"><span class="w">enable</span></code>

command.</p>
<p>This is done for a breakpoint in the current file.</p>
</li>
<li><a name="enable-%5bfile%5d%3a%5bline%5d"></a><b>enable [file]:[line]


</b>
<p>Enable the breakpoint so it will stop the execution of the program.</p>
</li>
<li><a name="enable-%5bline%5d"></a><b>enable [line]


</b>
<p>Enable the breakpoint so it will stop the execution of the program.</p>
<p>This is done for a breakpoint in the current file.</p>
</li>
<li><a name="a-%5bline%5d-command"></a><b>a [line] command
</b>
<p>Set an action to be done before the line is executed.  If <i>line</i> is
omitted, set an action on the line about to be executed.
The sequence of steps taken by the debugger is</p>
<pre class="verbatim"><ol><li>  1. check for a breakpoint at this line</li><li>  2. print the line if necessary (tracing)</li><li>  3. do any actions associated with that line</li><li>  4. prompt user if at a breakpoint or in single-step</li><li>  5. evaluate line</li></ol></pre><p>For example, this will print out $foo every time line
53 is passed:</p>
<pre class="verbatim"><ol><li>    <span class="w">a</span> <span class="n">53</span> <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;DB FOUND $foo\n&quot;</span></li></ol></pre></li>
<li><a name="A-line"></a><b>A line
</b>
<p>Delete an action from the specified line.</p>
</li>
<li><a name="A-*"></a><b>A *
</b>
<p>Delete all installed actions.</p>
</li>
<li><a name="w-expr"></a><b>w expr
</b>
<p>Add a global watch-expression. Whenever a watched global changes the
debugger will stop and display the old and new values.</p>
</li>
<li><a name="W-expr"></a><b>W expr
</b>
<p>Delete watch-expression</p>
</li>
<li><a name="W-*"></a><b>W *
</b>
<p>Delete all watch-expressions.</p>
</li>
<li><a name="o"></a><b>o
</b>
<p>Display all options.</p>
</li>
<li><a name="o-booloption-..."></a><b>o booloption ...
</b>
<p>Set each listed Boolean option to the value <code class="inline"><span class="n">1</span></code>
.</p>
</li>
<li><a name="o-anyoption%3f-..."></a><b>o anyoption? ...
</b>
<p>Print out the value of one or more options.</p>
</li>
<li><a name="o-option%3dvalue-..."></a><b>o option=value ...
</b>
<p>Set the value of one or more options.  If the value has internal
whitespace, it should be quoted.  For example, you could set <code class="inline"><span class="w">o</span>
<span class="w">pager</span>=<span class="q">&quot;less -MQeicsNfr&quot;</span></code>
 to call <b>less</b> with those specific options.
You may use either single or double quotes, but if you do, you must
escape any embedded instances of same sort of quote you began with,
as well as any escaping any escapes that immediately precede that
quote but which are not meant to escape the quote itself.  In other
words, you follow single-quoting rules irrespective of the quote;
eg: <code class="inline"><span class="w">o</span> <span class="w">option</span>=<span class="q">&#39;this isn\&#39;t bad&#39;</span></code>
 or <code class="inline"><span class="w">o</span> <span class="w">option</span>=<span class="q">&quot;She said, \&quot;Isn&#39;t</span>
<span class="q">it?\&quot;&quot;</span></code>
.</p>
<p>For historical reasons, the <code class="inline"><span class="pd">=value</span></code>
 is optional, but defaults to
1 only where it is safe to do so--that is, mostly for Boolean
options.  It is always better to assign a specific value using <code class="inline">=</code>
.
The <code class="inline"><span class="w">option</span></code>
 can be abbreviated, but for clarity probably should
not be.  Several options can be set together.  See <a href="#Configurable-Options">Configurable Options</a>
for a list of these.</p>
</li>
<li><a name="%3c-%3f"></a><b>&lt; ?
</b>
<p>List out all pre-prompt Perl command actions.</p>
</li>
<li><a name="%3c-%5b-command-%5d"></a><b>&lt; [ command ]
</b>
<p>Set an action (Perl command) to happen before every debugger prompt.
A multi-line command may be entered by backslashing the newlines.</p>
</li>
<li><a name="%3c-*"></a><b>&lt; *
</b>
<p>Delete all pre-prompt Perl command actions.</p>
</li>
<li><a name="%3c%3c-command"></a><b>&lt;&lt; command
</b>
<p>Add an action (Perl command) to happen before every debugger prompt.
A multi-line command may be entered by backwhacking the newlines.</p>
</li>
<li><a name="%3e-%3f"></a><b>&gt; ?
</b>
<p>List out post-prompt Perl command actions.</p>
</li>
<li><a name="%3e-command"></a><b>&gt; command
</b>
<p>Set an action (Perl command) to happen after the prompt when you've
just given a command to return to executing the script.  A multi-line
command may be entered by backslashing the newlines (we bet you
couldn't have guessed this by now).</p>
</li>
<li><a name="%3e-*"></a><b>&gt; *
</b>
<p>Delete all post-prompt Perl command actions.</p>
</li>
<li><a name="%3e%3e-command"></a><b>&gt;&gt; command
</b>
<p>Adds an action (Perl command) to happen after the prompt when you've
just given a command to return to executing the script.  A multi-line
command may be entered by backslashing the newlines.</p>
</li>
<li><a name="%7b-%3f"></a><b>{ ?
</b>
<p>List out pre-prompt debugger commands.</p>
</li>
<li><a name="%7b-%5b-command-%5d"></a><b>{ [ command ]</b>
<p>Set an action (debugger command) to happen before every debugger prompt.
A multi-line command may be entered in the customary fashion.</p>
<p>Because this command is in some senses new, a warning is issued if
you appear to have accidentally entered a block instead.  If that's
what you mean to do, write it as with <code class="inline"><span class="sc">;</span><span class="s">{</span> ... <span class="s">}</span></code>
 or even
<code class="inline"><a class="l_k" href="functions/do.html">do</a> <span class="s">{</span> ... <span class="s">}</span></code>
.</p>
</li>
<li><a name="%7b-*"></a><b>{ *
</b>
<p>Delete all pre-prompt debugger commands.</p>
</li>
<li><a name="%7b%7b-command"></a><b>{{ command
</b>
<p>Add an action (debugger command) to happen before every debugger prompt.
A multi-line command may be entered, if you can guess how: see above.</p>
</li>
<li><a name="!-number"></a><b>! number
</b>
<p>Redo a previous command (defaults to the previous command).</p>
</li>
<li><a name="!--number"></a><b>! -number
</b>
<p>Redo number'th previous command.</p>
</li>
<li><a name="!-pattern"></a><b>! pattern
</b>
<p>Redo last command that started with pattern.
See <code class="inline"><span class="w">o</span> <span class="w">recallCommand</span></code>
, too.</p>
</li>
<li><a name="!!-cmd"></a><b>!! cmd
</b>
<p>Run cmd in a subprocess (reads from DB::IN, writes to DB::OUT) See
<code class="inline"><span class="w">o</span> <span class="w">shellBang</span></code>
, also.  Note that the user's current shell (well,
their <code class="inline"><span class="i">$ENV</span>{<span class="w">SHELL</span>}</code>
 variable) will be used, which can interfere
with proper interpretation of exit status or signal and coredump
information.</p>
</li>
<li><a name="source-file"></a><b>source file
</b>
<p>Read and execute debugger commands from <i>file</i>.
<i>file</i> may itself contain <code class="inline"><span class="w">source</span></code>
 commands.</p>
</li>
<li><a name="H--number"></a><b>H -number
</b>
<p>Display last n commands.  Only commands longer than one character are
listed.  If <i>number</i> is omitted, list them all.</p>
</li>
<li><a name="q-or-%5eD"></a><b>q or ^D

</b>
<p>Quit.  ("quit" doesn't work for this, unless you've made an alias)
This is the only supported way to exit the debugger, though typing
<code class="inline"><a class="l_k" href="functions/exit.html">exit</a></code> twice might work.</p>
<p>Set the <code class="inline"><span class="w">inhibit_exit</span></code>
 option to 0 if you want to be able to step
off the end the script.  You may also need to set $finished to 0
if you want to step through global destruction.</p>
</li>
<li><a name="R"></a><b>R
</b>
<p>Restart the debugger by <code class="inline"><a class="l_k" href="functions/exec.html">exec()</a></code>ing a new session.  We try to maintain
your history across this, but internal settings and command-line options
may be lost.</p>
<p>The following setting are currently preserved: history, breakpoints,
actions, debugger options, and the Perl command-line
options <b>-w</b>, <b>-I</b>, and <b>-e</b>.</p>
</li>
<li><a name="%7cdbcmd"></a><b>|dbcmd
</b>
<p>Run the debugger command, piping DB::OUT into your current pager.</p>
</li>
<li><a name="%7c%7cdbcmd"></a><b>||dbcmd
</b>
<p>Same as <code class="inline">|dbcmd</code> but DB::OUT is temporarily <code class="inline"><a class="l_k" href="functions/select.html">select</a></code>ed as well.</p>
</li>
<li><a name="%3d-%5balias-value%5d"></a><b>= [alias value]
</b>
<p>Define a command alias, like</p>
<pre class="verbatim"><ol><li>    = quit q</li></ol></pre><p>or list current aliases.</p>
</li>
<li><a name="command"></a><b>command</b>
<p>Execute command as a Perl statement.  A trailing semicolon will be
supplied.  If the Perl statement would otherwise be confused for a
Perl debugger, use a leading semicolon, too.</p>
</li>
<li><a name="m-expr"></a><b>m expr
</b>
<p>List which methods may be called on the result of the evaluated
expression.  The expression may evaluated to a reference to a
blessed object, or to a package name.</p>
</li>
<li><a name="M"></a><b>M
</b>
<p>Display all loaded modules and their versions.</p>
</li>
<li><a name="man-%5bmanpage%5d"></a><b>man [manpage]
</b>
<p>Despite its name, this calls your system's default documentation
viewer on the given page, or on the viewer itself if <i>manpage</i> is
omitted.  If that viewer is <b>man</b>, the current <code class="inline"><span class="w">Config</span></code>
 information
is used to invoke <b>man</b> using the proper MANPATH or <b>-M</b>
<i>manpath</i> option.  Failed lookups of the form <code class="inline"><span class="w">XXX</span></code>
 that match
known manpages of the form <i>perlXXX</i> will be retried.  This lets
you type <code class="inline"><span class="w">man</span> <span class="w">debug</span></code>
 or <code class="inline"><span class="w">man</span> <span class="w">op</span></code>
 from the debugger.</p>
<p>On systems traditionally bereft of a usable <b>man</b> command, the
debugger invokes <b>perldoc</b>.  Occasionally this determination is
incorrect due to recalcitrant vendors or rather more felicitously,
to enterprising users.  If you fall into either category, just
manually set the $DB::doccmd variable to whatever viewer to view
the Perl documentation on your system.  This may be set in an rc
file, or through direct assignment.  We're still waiting for a
working example of something along the lines of:</p>
<pre class="verbatim"><ol><li>    <span class="i">$DB::doccmd</span> = <span class="q">&#39;netscape -remote <a href="http://something.here/">http://something.here/</a>&#39;</span><span class="sc">;</span></li></ol></pre></li>
</ul>
<a name="Configurable-Options"></a><h2>Configurable Options</h2>
<p>The debugger has numerous options settable using the <code class="inline"><span class="w">o</span></code>
 command,
either interactively or from the environment or an rc file.
(./.perldb or ~/.perldb under Unix.)</p>
<ul>
<li><a name="recallCommand%2c-ShellBang"></a><b><code class="inline"><span class="w">recallCommand</span></code>
, <code class="inline"><span class="w">ShellBang</span></code>


</b>
<p>The characters used to recall a command or spawn a shell.  By
default, both are set to <code class="inline">!</code>
, which is unfortunate.</p>
</li>
<li><a name="pager"></a><b><code class="inline"><span class="w">pager</span></code>

</b>
<p>Program to use for output of pager-piped commands (those beginning
with a <code class="inline">|</code> character.)  By default, <code class="inline"><span class="i">$ENV</span>{<span class="w">PAGER</span>}</code>
 will be used.
Because the debugger uses your current terminal characteristics
for bold and underlining, if the chosen pager does not pass escape
sequences through unchanged, the output of some debugger commands
will not be readable when sent through the pager.</p>
</li>
<li><a name="tkRunning"></a><b><code class="inline"><span class="w">tkRunning</span></code>

</b>
<p>Run Tk while prompting (with ReadLine).</p>
</li>
<li><a name="signalLevel%2c-warnLevel%2c-dieLevel"></a><b><code class="inline"><span class="w">signalLevel</span></code>
, <code class="inline"><span class="w">warnLevel</span></code>
, <code class="inline"><span class="w">dieLevel</span></code>

 
</b>
<p>Level of verbosity.  By default, the debugger leaves your exceptions
and warnings alone, because altering them can break correctly running
programs.  It will attempt to print a message when uncaught INT, BUS, or
SEGV signals arrive.  (But see the mention of signals in <a href="#BUGS">BUGS</a> below.)</p>
<p>To disable this default safe mode, set these values to something higher
than 0.  At a level of 1, you get backtraces upon receiving any kind
of warning (this is often annoying) or exception (this is
often valuable).  Unfortunately, the debugger cannot discern fatal
exceptions from non-fatal ones.  If <code class="inline"><span class="w">dieLevel</span></code>
 is even 1, then your
non-fatal exceptions are also traced and unceremoniously altered if they
came from <code class="inline"><a class="l_k" href="functions/eval.html">eval'ed</a></code> strings or from any kind of <code class="inline"><a class="l_k" href="functions/eval.html">eval</a></code> within modules
you're attempting to load.  If <code class="inline"><span class="w">dieLevel</span></code>
 is 2, the debugger doesn't
care where they came from:  It usurps your exception handler and prints
out a trace, then modifies all exceptions with its own embellishments.
This may perhaps be useful for some tracing purposes, but tends to hopelessly
destroy any program that takes its exception handling seriously.</p>
</li>
<li><a name="AutoTrace"></a><b><code class="inline"><span class="w">AutoTrace</span></code>

</b>
<p>Trace mode (similar to <code class="inline"><span class="w">t</span></code>
 command, but can be put into
<code class="inline"><span class="w">PERLDB_OPTS</span></code>
).</p>
</li>
<li><a name="LineInfo"></a><b><code class="inline"><span class="w">LineInfo</span></code>

</b>
<p>File or pipe to print line number info to.  If it is a pipe (say,
<code class="inline">|visual_perl_db</code>), then a short message is used.  This is the
mechanism used to interact with a slave editor or visual debugger,
such as the special <code class="inline"><span class="w">vi</span></code>
 or <code class="inline"><span class="w">emacs</span></code>
 hooks, or the <code class="inline"><span class="w">ddd</span></code>
 graphical
debugger.</p>
</li>
<li><a name="inhibit_exit"></a><b><code class="inline"><span class="w">inhibit_exit</span></code>

</b>
<p>If 0, allows <i>stepping off</i> the end of the script.</p>
</li>
<li><a name="PrintRet"></a><b><code class="inline"><span class="w">PrintRet</span></code>

</b>
<p>Print return value after <code class="inline"><span class="w">r</span></code>
 command if set (default).</p>
</li>
<li><a name="ornaments"></a><b><code class="inline"><span class="w">ornaments</span></code>

</b>
<p>Affects screen appearance of the command line (see <a href="Term/ReadLine.html">Term::ReadLine</a>).
There is currently no way to disable these, which can render
some output illegible on some displays, or with some pagers.
This is considered a bug.</p>
</li>
<li><a name="frame"></a><b><code class="inline"><span class="w">frame</span></code>

</b>
<p>Affects the printing of messages upon entry and exit from subroutines.  If
<code class="inline"><span class="w">frame</span> <span class="i">&amp; 2</span></code>
 is false, messages are printed on entry only. (Printing
on exit might be useful if interspersed with other messages.)</p>
<p>If <code class="inline"><span class="w">frame</span> <span class="i">&amp; 4</span></code>
, arguments to functions are printed, plus context
and caller info.  If <code class="inline"><span class="w">frame</span> <span class="i">&amp; 8</span></code>
, overloaded <code class="inline"><span class="w">stringify</span></code>
 and
<code class="inline"><a class="l_k" href="functions/tie.html">tie</a></code>d <code class="inline"><span class="w">FETCH</span></code>
 is enabled on the printed arguments.  If <code class="inline"><span class="w">frame</span>
<span class="i">&amp; 16</span></code>
, the return value from the subroutine is printed.</p>
<p>The length at which the argument list is truncated is governed by the
next option:</p>
</li>
<li><a name="maxTraceLen"></a><b><code class="inline"><span class="w">maxTraceLen</span></code>

</b>
<p>Length to truncate the argument list when the <code class="inline"><span class="w">frame</span></code>
 option's
bit 4 is set.</p>
</li>
<li><a name="windowSize"></a><b><code class="inline"><span class="w">windowSize</span></code>

</b>
<p>Change the size of code list window (default is 10 lines).</p>
</li>
</ul>
<p>The following options affect what happens with <code class="inline"><span class="w">V</span></code>
, <code class="inline"><span class="w">X</span></code>
, and <code class="inline"><span class="w">x</span></code>

commands:</p>
<ul>
<li><a name="arrayDepth%2c-hashDepth"></a><b><code class="inline"><span class="w">arrayDepth</span></code>
, <code class="inline"><span class="w">hashDepth</span></code>

 </b>
<p>Print only first N elements ('' for all).</p>
</li>
<li><a name="dumpDepth"></a><b><code class="inline"><span class="w">dumpDepth</span></code>

</b>
<p>Limit recursion depth to N levels when dumping structures.
Negative values are interpreted as infinity.  Default: infinity.</p>
</li>
<li><a name="compactDump%2c-veryCompact"></a><b><code class="inline"><span class="w">compactDump</span></code>
, <code class="inline"><span class="w">veryCompact</span></code>

 </b>
<p>Change the style of array and hash output.  If <code class="inline"><span class="w">compactDump</span></code>
, short array
may be printed on one line.</p>
</li>
<li><a name="globPrint"></a><b><code class="inline"><span class="w">globPrint</span></code>

</b>
<p>Whether to print contents of globs.</p>
</li>
<li><a name="DumpDBFiles"></a><b><code class="inline"><span class="w">DumpDBFiles</span></code>

</b>
<p>Dump arrays holding debugged files.</p>
</li>
<li><a name="DumpPackages"></a><b><code class="inline"><span class="w">DumpPackages</span></code>

</b>
<p>Dump symbol tables of packages.</p>
</li>
<li><a name="DumpReused"></a><b><code class="inline"><span class="w">DumpReused</span></code>

</b>
<p>Dump contents of "reused" addresses.</p>
</li>
<li><a name="quote%2c-HighBit%2c-undefPrint"></a><b><code class="inline"><span class="w">quote</span></code>
, <code class="inline"><span class="w">HighBit</span></code>
, <code class="inline"><span class="w">undefPrint</span></code>

 
</b>
<p>Change the style of string dump.  The default value for <code class="inline"><span class="w">quote</span></code>

is <code class="inline"><span class="w">auto</span></code>
; one can enable double-quotish or single-quotish format
by setting it to <code class="inline">"</code> or <code class="inline">'</code>, respectively.  By default, characters
with their high bit set are printed verbatim.</p>
</li>
<li><a name="UsageOnly"></a><b><code class="inline"><span class="w">UsageOnly</span></code>

</b>
<p>Rudimentary per-package memory usage dump.  Calculates total
size of strings found in variables in the package.  This does not
include lexicals in a module's file scope, or lost in closures.</p>
</li>
<li><a name="HistFile"></a><b><code class="inline"><span class="w">HistFile</span></code>

</b>
<p>The path of the file from which the history (assuming a usable
Term::ReadLine backend) will be read on the debugger's startup, and to which
it will be saved on shutdown (for persistence across sessions). Similar in
concept to Bash's <code class="inline">.<span class="w">bash_history</span></code>
 file.</p>
</li>
<li><a name="HistSize"></a><b><code class="inline"><span class="w">HistSize</span></code>

</b>
<p>The count of the saved lines in the history (assuming <code class="inline"><span class="w">HistFile</span></code>
 above).</p>
</li>
</ul>
<p>After the rc file is read, the debugger reads the <code class="inline"><span class="i">$ENV</span>{<span class="w">PERLDB_OPTS</span>}</code>

environment variable and parses this as the remainder of a "O ..."
line as one might enter at the debugger prompt.  You may place the
initialization options <code class="inline"><span class="w">TTY</span></code>
, <code class="inline"><span class="w">noTTY</span></code>
, <code class="inline"><span class="w">ReadLine</span></code>
, and <code class="inline"><span class="w">NonStop</span></code>

there.</p>
<p>If your rc file contains:</p>
<pre class="verbatim"><ol><li>  <span class="i">parse_options</span><span class="s">(</span><span class="q">&quot;NonStop=1 LineInfo=db.out AutoTrace&quot;</span><span class="s">)</span><span class="sc">;</span></li></ol></pre><p>then your script will run without human intervention, putting trace
information into the file <i>db.out</i>.  (If you interrupt it, you'd
better reset <code class="inline"><span class="w">LineInfo</span></code>
 to <i>/dev/tty</i> if you expect to see anything.)</p>
<ul>
<li><a name="TTY"></a><b><code class="inline"><span class="w">TTY</span></code>

</b>
<p>The TTY to use for debugging I/O.</p>
</li>
<li><a name="noTTY"></a><b><code class="inline"><span class="w">noTTY</span></code>

</b>
<p>If set, the debugger goes into <code class="inline"><span class="w">NonStop</span></code>
 mode and will not connect to a TTY.  If
interrupted (or if control goes to the debugger via explicit setting of
$DB::signal or $DB::single from the Perl script), it connects to a TTY
specified in the <code class="inline"><span class="w">TTY</span></code>
 option at startup, or to a tty found at
runtime using the <code class="inline"><span class="w">Term::Rendezvous</span></code>
 module of your choice.</p>
<p>This module should implement a method named <code class="inline"><span class="w">new</span></code>
 that returns an object
with two methods: <code class="inline"><span class="w">IN</span></code>
 and <code class="inline"><span class="w">OUT</span></code>
.  These should return filehandles to use
for debugging input and output correspondingly.  The <code class="inline"><span class="w">new</span></code>
 method should
inspect an argument containing the value of <code class="inline"><span class="i">$ENV</span>{<span class="w">PERLDB_NOTTY</span>}</code>
 at
startup, or <code class="inline"><span class="q">&quot;$ENV{HOME}/.perldbtty$$&quot;</span></code>
 otherwise.  This file is not
inspected for proper ownership, so security hazards are theoretically
possible.</p>
</li>
<li><a name="ReadLine"></a><b><code class="inline"><span class="w">ReadLine</span></code>

</b>
<p>If false, readline support in the debugger is disabled in order
to debug applications that themselves use ReadLine.</p>
</li>
<li><a name="NonStop"></a><b><code class="inline"><span class="w">NonStop</span></code>

</b>
<p>If set, the debugger goes into non-interactive mode until interrupted, or
programmatically by setting $DB::signal or $DB::single.</p>
</li>
</ul>
<p>Here's an example of using the <code class="inline"><span class="i">$ENV</span>{<span class="w">PERLDB_OPTS</span>}</code>
 variable:</p>
<pre class="verbatim"><ol><li>    $ PERLDB_OPTS="NonStop frame=2" perl -d myprogram</li></ol></pre><p>That will run the script <b>myprogram</b> without human intervention,
printing out the call tree with entry and exit points.  Note that
<code class="inline">NonStop=1 frame=2</code> is equivalent to <code class="inline"><span class="w">N</span> <span class="w">f</span>=<span class="n">2</span></code>
, and that originally,
options could be uniquely abbreviated by the first letter (modulo
the <code class="inline"><span class="w">Dump</span>*</code>
 options).  It is nevertheless recommended that you
always spell them out in full for legibility and future compatibility.</p>
<p>Other examples include</p>
<pre class="verbatim"><ol><li>    $ PERLDB_OPTS="NonStop LineInfo=listing frame=2" perl -d myprogram</li></ol></pre><p>which runs script non-interactively, printing info on each entry
into a subroutine and each executed line into the file named <i>listing</i>.
(If you interrupt it, you would better reset <code class="inline"><span class="w">LineInfo</span></code>
 to something
"interactive"!)</p>
<p>Other examples include (using standard shell syntax to show environment
variable settings):</p>
<pre class="verbatim"><ol><li>  $ ( PERLDB_OPTS="NonStop frame=1 AutoTrace LineInfo=tperl.out"</li><li>      perl -d myprogram )</li></ol></pre><p>which may be useful for debugging a program that uses <code class="inline"><span class="w">Term::ReadLine</span></code>

itself.  Do not forget to detach your shell from the TTY in the window that
corresponds to <i>/dev/ttyXX</i>, say, by issuing a command like</p>
<pre class="verbatim"><ol><li>  $ sleep 1000000</li></ol></pre><p>See <a href="perldebguts.html#Debugger-Internals">Debugger Internals in perldebguts</a> for details.</p>
<a name="Debugger-Input%2fOutput"></a><h2>Debugger Input/Output</h2>
<ul>
<li><a name="Prompt"></a><b>Prompt</b>
<p>The debugger prompt is something like</p>
<pre class="verbatim"><ol><li>    <span class="w">DB</span><span class="q">&lt;8&gt;</span></li></ol></pre><p>or even</p>
<pre class="verbatim"><ol><li>    DB&lt;&lt;17&gt;&gt;</li></ol></pre><p>where that number is the command number, and which you'd use to
access with the built-in <b>csh</b>-like history mechanism.  For example,
<code class="inline">!<span class="n">17</span></code>
 would repeat command number 17.  The depth of the angle
brackets indicates the nesting depth of the debugger.  You could
get more than one set of brackets, for example, if you'd already
at a breakpoint and then printed the result of a function call that
itself has a breakpoint, or you step into an expression via <code class="inline">s/n/t
expression</code> command.</p>
</li>
<li><a name="Multiline-commands"></a><b>Multiline commands</b>
<p>If you want to enter a multi-line command, such as a subroutine
definition with several statements or a format, escape the newline
that would normally end the debugger command with a backslash.
Here's an example:</p>
<pre class="verbatim"><ol><li>      DB&lt;1&gt; for (1..4) {         \</li><li>      cont:     print "ok\n";   \</li><li>      cont: }</li><li>      ok</li><li>      ok</li><li>      ok</li><li>      ok</li></ol></pre><p>Note that this business of escaping a newline is specific to interactive
commands typed into the debugger.</p>
</li>
<li><a name="Stack-backtrace"></a><b>Stack backtrace
 </b>
<p>Here's an example of what a stack backtrace via <code class="inline"><span class="w">T</span></code>
 command might
look like:</p>
<pre class="verbatim"><ol><li> <span class="i">$ =</span> <span class="w">main::infested</span> <span class="w">called</span> <span class="w">from</span> <span class="w">file</span> <span class="q">&#39;Ambulation.pm&#39;</span> <span class="w">line</span> <span class="n">10</span></li><li> <span class="i">@ =</span> <span class="i">Ambulation::legs</span><span class="s">(</span><span class="n">1</span><span class="cm">,</span> <span class="n">2</span><span class="cm">,</span> <span class="n">3</span><span class="cm">,</span> <span class="n">4</span><span class="s">)</span> <span class="w">called</span> <span class="w">from</span> <span class="w">file</span> <span class="q">&#39;camel_flea&#39;</span></li><li>                                                          <span class="w">line</span> <span class="n">7</span></li><li> <span class="i">$ =</span> <span class="i">main::pests</span><span class="s">(</span><span class="q">&#39;bactrian&#39;</span><span class="cm">,</span> <span class="n">4</span><span class="s">)</span> <span class="w">called</span> <span class="w">from</span> <span class="w">file</span> <span class="q">&#39;camel_flea&#39;</span></li><li>                                                          <span class="w">line</span> <span class="n">4</span></li></ol></pre><p>The left-hand character up there indicates the context in which the
function was called, with <code class="inline"><span class="i">$</span></code>
 and <code class="inline"><span class="i">@</span></code>
 meaning scalar or list
contexts respectively, and <code class="inline">.</code> meaning void context (which is
actually a sort of scalar context).  The display above says
that you were in the function <code class="inline"><span class="w">main::infested</span></code>
 when you ran the
stack dump, and that it was called in scalar context from line
10 of the file <i>Ambulation.pm</i>, but without any arguments at all,
meaning it was called as <code class="inline"><span class="i">&amp;infested</span></code>
.  The next stack frame shows
that the function <code class="inline"><span class="w">Ambulation::legs</span></code>
 was called in list context
from the <i>camel_flea</i> file with four arguments.  The last stack
frame shows that <code class="inline"><span class="w">main::pests</span></code>
 was called in scalar context,
also from <i>camel_flea</i>, but from line 4.</p>
<p>If you execute the <code class="inline"><span class="w">T</span></code>
 command from inside an active <code class="inline"><a class="l_k" href="functions/use.html">use</a></code>
statement, the backtrace will contain both a <code class="inline"><a class="l_k" href="functions/require.html">require</a></code> frame and
an <code class="inline"><a class="l_k" href="functions/eval.html">eval</a></code> frame.</p>
</li>
<li><a name="Line-Listing-Format"></a><b>Line Listing Format</b>
<p>This shows the sorts of output the <code class="inline"><span class="w">l</span></code>
 command can produce:</p>
<pre class="verbatim"><ol><li>   <span class="w">DB</span><span class="h">&lt;&lt;13</span>&gt;&gt; <span class="w">l</span></li><li><span class="hh"> 101:        @i{@i} = ();</span></li><li><span class="hh"> 102:b       @isa{@i,$pack} = ()</span></li><li><span class="hh"> 103             if(exists $i{$prevpack} || exists $isa{$pack});</span></li><li><span class="hh"> 104     }</span></li><li><span class="hh"> 105</span></li><li><span class="hh"> 106     next</span></li><li><span class="hh"> 107==&gt;      if(exists $isa{$pack});</span></li><li><span class="hh"> 108</span></li><li><span class="hh"> 109:a   if ($extra-- &gt; 0) {</span></li><li><span class="hh"> 110:        %isa = ($pack,1);</span></li></ol></pre><p>Breakable lines are marked with <code class="inline"><span class="j">:</span></code>
.  Lines with breakpoints are
marked by <code class="inline"><span class="w">b</span></code>
 and those with actions by <code class="inline"><span class="w">a</span></code>
.  The line that's
about to be executed is marked by <code class="inline">==&gt;</code>.</p>
<p>Please be aware that code in debugger listings may not look the same
as your original source code.  Line directives and external source
filters can alter the code before Perl sees it, causing code to move
from its original positions or take on entirely different forms.</p>
</li>
<li><a name="Frame-listing"></a><b>Frame listing</b>
<p>When the <code class="inline"><span class="w">frame</span></code>
 option is set, the debugger would print entered (and
optionally exited) subroutines in different styles.  See <a href="perldebguts.html">perldebguts</a>
for incredibly long examples of these.</p>
</li>
</ul>
<a name="Debugging-Compile-Time-Statements"></a><h2>Debugging Compile-Time Statements</h2>
<p>If you have compile-time executable statements (such as code within
BEGIN, UNITCHECK and CHECK blocks or <code class="inline"><a class="l_k" href="functions/use.html">use</a></code> statements), these will
<i>not</i> be stopped by debugger, although <code class="inline"><a class="l_k" href="functions/require.html">require</a></code>s and INIT blocks
will, and compile-time statements can be traced with the <code class="inline"><span class="w">AutoTrace</span></code>

option set in <code class="inline"><span class="w">PERLDB_OPTS</span></code>
).  From your own Perl code, however, you
can transfer control back to the debugger using the following
statement, which is harmless if the debugger is not running:</p>
<pre class="verbatim"><ol><li>    <span class="i">$DB::single</span> = <span class="n">1</span><span class="sc">;</span></li></ol></pre><p>If you set <code class="inline"><span class="i">$DB::single</span></code>
 to 2, it's equivalent to having
just typed the <code class="inline"><span class="w">n</span></code>
 command, whereas a value of 1 means the <code class="inline"><a class="l_k" href="functions/s.html">s</a></code>
command.  The <code class="inline"><span class="i">$DB::trace</span></code>
  variable should be set to 1 to simulate
having typed the <code class="inline"><span class="w">t</span></code>
 command.</p>
<p>Another way to debug compile-time code is to start the debugger, set a
breakpoint on the <i>load</i> of some module:</p>
<pre class="verbatim"><ol><li>    <span class="w">DB</span><span class="q">&lt;7&gt;</span> <span class="w">b</span> <span class="w">load</span> <span class="w">f</span><span class="co">:</span><span class="q">/perllib/</span><span class="w">lib</span>/<span class="w">Carp</span>.<span class="w">pm</span></li><li>  <span class="w">Will</span> <span class="w">stop</span> <span class="w">on</span> <span class="w">load</span> <span class="w">of</span> <span class="q">&#39;f:/perllib/lib/Carp.pm&#39;</span>.</li></ol></pre><p>and then restart the debugger using the <code class="inline"><span class="w">R</span></code>
 command (if possible).  One can use <code class="inline"><span class="w">b</span>
<span class="w">compile</span> <span class="w">subname</span></code>
 for the same purpose.</p>
<a name="Debugger-Customization"></a><h2>Debugger Customization</h2>
<p>The debugger probably contains enough configuration hooks that you
won't ever have to modify it yourself.  You may change the behaviour
of the debugger from within the debugger using its <code class="inline"><span class="w">o</span></code>
 command, from
the command line via the <code class="inline"><span class="w">PERLDB_OPTS</span></code>
 environment variable, and
from customization files.</p>
<p>You can do some customization by setting up a <i>.perldb</i> file, which
contains initialization code.  For instance, you could make aliases
like these (the last one is one people expect to be there):</p>
<pre class="verbatim"><ol><li>    <span class="i">$DB::alias</span>{<span class="q">&#39;len&#39;</span>}  = <span class="q">&#39;s/^len(.*)/p length($1)/&#39;</span><span class="sc">;</span></li><li>    <span class="i">$DB::alias</span>{<span class="q">&#39;stop&#39;</span>} = <span class="q">&#39;s/^stop (at|in)/b/&#39;</span><span class="sc">;</span></li><li>    <span class="i">$DB::alias</span>{<span class="q">&#39;ps&#39;</span>}   = <span class="q">&#39;s/^ps\b/p scalar /&#39;</span><span class="sc">;</span></li><li>    <span class="i">$DB::alias</span>{<span class="q">&#39;quit&#39;</span>} = <span class="q">&#39;s/^quit(\s*)/exit/&#39;</span><span class="sc">;</span></li></ol></pre><p>You can change options from <i>.perldb</i> by using calls like this one;</p>
<pre class="verbatim"><ol><li>    <span class="i">parse_options</span><span class="s">(</span><span class="q">&quot;NonStop=1 LineInfo=db.out AutoTrace=1 frame=2&quot;</span><span class="s">)</span><span class="sc">;</span></li></ol></pre><p>The code is executed in the package <code class="inline"><span class="w">DB</span></code>
.  Note that <i>.perldb</i> is
processed before processing <code class="inline"><span class="w">PERLDB_OPTS</span></code>
.  If <i>.perldb</i> defines the
subroutine <code class="inline"><span class="w">afterinit</span></code>
, that function is called after debugger
initialization ends.  <i>.perldb</i> may be contained in the current
directory, or in the home directory.  Because this file is sourced
in by Perl and may contain arbitrary commands, for security reasons,
it must be owned by the superuser or the current user, and writable
by no one but its owner.</p>
<p>You can mock TTY input to debugger by adding arbitrary commands to
@DB::typeahead. For example, your <i>.perldb</i> file might contain:</p>
<pre class="verbatim"><ol><li><a name="afterinit"></a>    sub <span class="m">afterinit</span> <span class="s">{</span> <a class="l_k" href="functions/push.html">push</a> <span class="i">@DB::typeahead</span><span class="cm">,</span> <span class="q">&quot;b 4&quot;</span><span class="cm">,</span> <span class="q">&quot;b 6&quot;</span><span class="sc">;</span> <span class="s">}</span></li></ol></pre><p>Which would attempt to set breakpoints on lines 4 and 6 immediately
after debugger initialization. Note that @DB::typeahead is not a supported
interface and is subject to change in future releases.</p>
<p>If you want to modify the debugger, copy <i>perl5db.pl</i> from the
Perl library to another name and hack it to your heart's content.
You'll then want to set your <code class="inline"><span class="w">PERL5DB</span></code>
 environment variable to say
something like this:</p>
<pre class="verbatim"><ol><li>    BEGIN <span class="s">{</span> <a class="l_k" href="functions/require.html">require</a> <span class="q">&quot;myperl5db.pl&quot;</span> <span class="s">}</span></li></ol></pre><p>As a last resort, you could also use <code class="inline"><span class="w">PERL5DB</span></code>
 to customize the debugger
by directly setting internal variables or calling debugger functions.</p>
<p>Note that any variables and functions that are not documented in
this document (or in <a href="perldebguts.html">perldebguts</a>) are considered for internal
use only, and as such are subject to change without notice.</p>
<a name="Readline-Support-%2f-History-in-the-Debugger"></a><h2>Readline Support / History in the Debugger</h2>
<p>As shipped, the only command-line history supplied is a simplistic one
that checks for leading exclamation points.  However, if you install
the Term::ReadKey and Term::ReadLine modules from CPAN (such as
Term::ReadLine::Gnu, Term::ReadLine::Perl, ...) you will
have full editing capabilities much like those GNU <i>readline</i>(3) provides.
Look for these in the <i>modules/by-module/Term</i> directory on CPAN.
These do not support normal <b>vi</b> command-line editing, however.</p>
<p>A rudimentary command-line completion is also available, including
lexical variables in the current scope if the <code class="inline"><span class="w">PadWalker</span></code>
 module
is installed.</p>
<p>Without Readline support you may see the symbols "^[[A", "^[[C", "^[[B",
"^[[D"", "^H", ... when using the arrow keys and/or the backspace key.</p>
<a name="Editor-Support-for-Debugging"></a><h2>Editor Support for Debugging</h2>
<p>If you have the GNU's version of <b>emacs</b> installed on your system,
it can interact with the Perl debugger to provide an integrated
software development environment reminiscent of its interactions
with C debuggers.</p>
<p>Recent versions of Emacs come with a
start file for making <b>emacs</b> act like a
syntax-directed editor that understands (some of) Perl's syntax.
See <a href="perlfaq3.html">perlfaq3</a>.</p>
<p>Users of <b>vi</b> should also look into <b>vim</b> and <b>gvim</b>, the mousey
and windy version, for coloring of Perl keywords.</p>
<p>Note that only perl can truly parse Perl, so all such CASE tools
fall somewhat short of the mark, especially if you don't program
your Perl as a C programmer might.</p>
<a name="The-Perl-Profiler"></a><h2>The Perl Profiler
  </h2>
<p>If you wish to supply an alternative debugger for Perl to run,
invoke your script with a colon and a package argument given to the
<b>-d</b> flag.  Perl's alternative debuggers include a Perl profiler,
<a href="http://search.cpan.org/perldoc/Devel::NYTProf">Devel::NYTProf</a>, which is available separately as a CPAN
distribution.  To profile your Perl program in the file <i>mycode.pl</i>,
just type:</p>
<pre class="verbatim"><ol><li>    <span class="i">$ perl</span> -<span class="w">d</span><span class="co">:</span><span class="w">NYTProf</span> <span class="w">mycode</span>.<span class="w">pl</span></li></ol></pre><p>When the script terminates the profiler will create a database of the
profile information that you can turn into reports using the profiler's
tools. See &lt;perlperf&gt; for details.</p>
<a name="Debugging-Regular-Expressions"></a><h1>Debugging Regular Expressions

 </h1>
<p><code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">re</span> <span class="q">&#39;debug&#39;</span></code>
 enables you to see the gory details of how the Perl
regular expression engine works. In order to understand this typically
voluminous output, one must not only have some idea about how regular
expression matching works in general, but also know how Perl's regular
expressions are internally compiled into an automaton. These matters
are explored in some detail in
<a href="perldebguts.html#Debugging-Regular-Expressions">Debugging Regular Expressions in perldebguts</a>.</p>
<a name="Debugging-Memory-Usage"></a><h1>Debugging Memory Usage
</h1>
<p>Perl contains internal support for reporting its own memory usage,
but this is a fairly advanced concept that requires some understanding
of how memory allocation works.
See <a href="perldebguts.html#Debugging-Perl-Memory-Usage">Debugging Perl Memory Usage in perldebguts</a> for the details.</p>
<a name="SEE-ALSO"></a><h1>SEE ALSO</h1>
<p>You do have <code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">strict</span></code>
 and <code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">warnings</span></code>
 enabled, don't you?</p>
<p><a href="perldebtut.html">perldebtut</a>,
<a href="perldebguts.html">perldebguts</a>,
<a href="re.html">re</a>,
<a href="DB.html">DB</a>,
<a href="http://search.cpan.org/perldoc/Devel::NYTProf">Devel::NYTProf</a>,
<a href="Dumpvalue.html">Dumpvalue</a>,
and
<a href="perlrun.html">perlrun</a>.</p>
<p>When debugging a script that uses #! and is thus normally found in
$PATH, the -S option causes perl to search $PATH for it, so you don't
have to type the path or <code class="inline"><span class="w">which</span> <span class="i">$scriptname</span></code>
.</p>
<pre class="verbatim"><ol><li>  <span class="i">$ perl</span> -<span class="w">Sd</span> <span class="w">foo</span>.<span class="w">pl</span></li></ol></pre><a name="BUGS"></a><h1>BUGS</h1>
<p>You cannot get stack frame information or in any fashion debug functions
that were not compiled by Perl, such as those from C or C++ extensions.</p>
<p>If you alter your @_ arguments in a subroutine (such as with <code class="inline"><a class="l_k" href="functions/shift.html">shift</a></code>
or <code class="inline"><a class="l_k" href="functions/pop.html">pop</a></code>), the stack backtrace will not show the original values.</p>
<p>The debugger does not currently work in conjunction with the <b>-W</b>
command-line switch, because it itself is not free of warnings.</p>
<p>If you're in a slow syscall (like <code class="inline"><a class="l_k" href="functions/wait.html">wait</a></code>ing, <code class="inline"><a class="l_k" href="functions/accept.html">accept</a></code>ing, or <code class="inline"><a class="l_k" href="functions/read.html">read</a></code>ing
from your keyboard or a socket) and haven't set up your own <code class="inline"><span class="i">$SIG</span>{<span class="w">INT</span>}</code>

handler, then you won't be able to CTRL-C your way back to the debugger,
because the debugger's own <code class="inline"><span class="i">$SIG</span>{<span class="w">INT</span>}</code>
 handler doesn't understand that
it needs to raise an exception to longjmp(3) out of slow syscalls.</p>




  <div id="page_index" class="hud_container">
    <div id="page_index_header" class="hud_header">
      <div id="page_index_close" class="hud_close"><a href="#" onClick="pageIndex.hide();return false;"></a></div>
      <div id="page_index_title" class="hud_title"><span class="hud_span_top">Page index</span></div>
      <div id="page_index_topright" class="hud_topright"></div>
    </div>
    <div id="page_index_content" class="hud_content">
      <ul><li><a href="#NAME">NAME
 </a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#The-Perl-Debugger">The Perl Debugger</a><ul><li><a href="#Calling-the-Debugger">Calling the Debugger</a><li><a href="#Debugger-Commands">Debugger Commands</a><li><a href="#Configurable-Options">Configurable Options</a><li><a href="#Debugger-Input%2fOutput">Debugger Input/Output</a><li><a href="#Debugging-Compile-Time-Statements">Debugging Compile-Time Statements</a><li><a href="#Debugger-Customization">Debugger Customization</a><li><a href="#Readline-Support-%2f-History-in-the-Debugger">Readline Support / History in the Debugger</a><li><a href="#Editor-Support-for-Debugging">Editor Support for Debugging</a><li><a href="#The-Perl-Profiler">The Perl Profiler
  </a></ul><li><a href="#Debugging-Regular-Expressions">Debugging Regular Expressions

 </a><li><a href="#Debugging-Memory-Usage">Debugging Memory Usage
</a><li><a href="#SEE-ALSO">SEE ALSO</a><li><a href="#BUGS">BUGS</a></ul>
    </div>
    <div id="page_index_footer" class="hud_footer">
      <div id="page_index_bottomleft" class="hud_bottomleft"></div>
      <div id="page_index_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
      <div id="page_index_resize" class="hud_resize"></div>
    </div>
  </div>


	    &nbsp;
          </div>
          <div id="content_footer">
          </div>
        </div>
        <div class="clear"></div>
      </div>
      
    <div id="footer">
      <div id="footer_content">
        <div id="footer_strapline">
          perldoc.perl.org - Official documentation for the Perl programming language
        </div>
        <div id="footer_links">
          <div id="address">
            <p class="name">Contact details</p>
            <p class="address">
	      Site maintained by <a href="mailto:jj@jonallen.info">Jon Allen (JJ)</a><br>
	    </p>
            <p class="contact">
              Documentation maintained by the <a href="http://lists.cpan.org/showlist.cgi?name=perl5-porters">Perl 5 Porters</a>
            </p>
          </div>
          <ul class="f1">
            <li>Manual
              <ul class="f2">
                <li><a href="index-overview.html">Overview</a>
                <li><a href="index-tutorials.html">Tutorials</a>
                <li><a href="index-faq.html">FAQs</a>
                <li><a href="index-history.html">Changes</a>
              </ul>
            <li>Reference
              <ul class="f2">
                <li><a href="index-language.html">Language</a>
                <li><a href="index-functions.html">Functions</a>
                <li><a href="perlop.html">Operators</a>
                <li><a href="perlvar.html">Variables</a>
              </ul>
            <li>Modules
              <ul class="f2">
                <li><a href="index-modules-A.html">Modules</a>
                <li><a href="index-pragmas.html">Pragmas</a>
                <li><a href="index-utilities.html">Utilities</a>
              </ul>
            <li>Misc
              <ul class="f2">
                <li><a href="index-licence.html">License</a>
                <li><a href="index-internals.html">Internals</a>
                <li><a href="index-platforms.html">Platforms</a>
              </ul>          </ul>
          <div class="clear"></div>
        </div>
      </div>
      <div id="footer_end">
      </div>
    </div>
      
    </div>
      <script language="JavaScript" type="text/javascript" src="static/exploreperl.js"></script>
      <script language="JavaScript" src="static/combined-20100403.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
  perldoc.setPath(0);
  perldoc.pageName    = 'perldebug';
  perldoc.pageAddress = 'perldebug.html';
  perldoc.contentPage = 1;
  explorePerl.render();
  explorePerl.addEvents('explore_anchor');
</script>
    
  </body>
</html>