File: perlrun.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 (1590 lines) | stat: -rw-r--r-- 102,315 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
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>perlrun - 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>perlrun</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-overview.html">Overview</a> &gt;
      
    
    perlrun
  

            </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>perlrun</h1>


  <!--    -->
<ul><li><a href="#NAME">NAME</a><li><a href="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><ul><li><a href="#%23!-and-quoting-on-non-Unix-systems">#! and quoting on non-Unix systems
 </a><li><a href="#Location-of-Perl">Location of Perl
</a><li><a href="#Command-Switches">Command Switches
 </a></ul><li><a href="#ENVIRONMENT">ENVIRONMENT
</a></ul><a name="NAME"></a><h1>NAME</h1>
<p>perlrun - how to execute the Perl interpreter</p>
<a name="SYNOPSIS"></a><h1>SYNOPSIS</h1>
<p><b>perl</b>	[ <b>-sTtuUWX</b> ]
	[ <b>-hv</b> ] [ <b>-V</b>[:<i>configvar</i>] ]
	[ <b>-cw</b> ] [ <b>-d</b>[<b>t</b>][:<i>debugger</i>] ] [ <b>-D</b>[<i>number/list</i>] ]
	[ <b>-pna</b> ] [ <b>-F</b><i>pattern</i> ] [ <b>-l</b>[<i>octal</i>] ] [ <b>-0</b>[<i>octal/hexadecimal</i>] ]
	[ <b>-I</b><i>dir</i> ] [ <b>-m</b>[<b>-</b>]<i>module</i> ] [ <b>-M</b>[<b>-</b>]<i>'module...'</i> ] [ <b>-f</b> ]
	[ <b>-C [<i>number/list</i>] </b>]
	[ <b>-S</b> ]
	[ <b>-x</b>[<i>dir</i>] ]
	[ <b>-i</b>[<i>extension</i>] ]
	[ [<b>-e</b>|<b>-E</b>] <i>'command'</i> ] [ <b>--</b> ] [ <i>programfile</i> ] [ <i>argument</i> ]...</p>
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
<p>The normal way to run a Perl program is by making it directly
executable, or else by passing the name of the source file as an
argument on the command line.  (An interactive Perl environment
is also possible--see <a href="perldebug.html">perldebug</a> for details on how to do that.)
Upon startup, Perl looks for your program in one of the following
places:</p>
<dl>
<dt>1.</dt><dd>
<p>Specified line by line via <b>-e</b> or <b>-E</b> switches on the command line.</p>
</dd>
<dt>2.</dt><dd>
<p>Contained in the file specified by the first filename on the command line.
(Note that systems supporting the <code class="inline"><span class="c">#!</span></code>
 notation invoke interpreters this
way. See <a href="#Location-of-Perl">Location of Perl</a>.)</p>
</dd>
<dt>3.</dt><dd>
<p>Passed in implicitly via standard input.  This works only if there are
no filename arguments--to pass arguments to a STDIN-read program you
must explicitly specify a "-" for the program name.</p>
</dd>
</dl>
<p>With methods 2 and 3, Perl starts parsing the input file from the
beginning, unless you've specified a <b>-x</b> switch, in which case it
scans for the first line starting with <code class="inline"><span class="c">#!</span></code>
 and containing the word
"perl", and starts there instead.  This is useful for running a program
embedded in a larger message.  (In this case you would indicate the end
of the program using the <code class="inline"><a name="__END__"></a>__END__</code>
 token.)</p>
<p>The <code class="inline"><span class="c">#!</span></code>
 line is always examined for switches as the line is being
parsed.  Thus, if you're on a machine that allows only one argument
with the <code class="inline"><span class="c">#!</span></code>
 line, or worse, doesn't even recognize the <code class="inline"><span class="c">#!</span></code>
 line, you
still can get consistent switch behaviour regardless of how Perl was
invoked, even if <b>-x</b> was used to find the beginning of the program.</p>
<p>Because historically some operating systems silently chopped off
kernel interpretation of the <code class="inline"><span class="c">#!</span></code>
 line after 32 characters, some
switches may be passed in on the command line, and some may not;
you could even get a "-" without its letter, if you're not careful.
You probably want to make sure that all your switches fall either
before or after that 32-character boundary.  Most switches don't
actually care if they're processed redundantly, but getting a "-"
instead of a complete switch could cause Perl to try to execute
standard input instead of your program.  And a partial <b>-I</b> switch
could also cause odd results.</p>
<p>Some switches do care if they are processed twice, for instance
combinations of <b>-l</b> and <b>-0</b>.  Either put all the switches after
the 32-character boundary (if applicable), or replace the use of
<b>-0</b><i>digits</i> by <code class="inline">BEGIN<span class="s">{</span> <span class="i">$/</span> = <span class="q">&quot;\0digits&quot;</span><span class="sc">;</span> <span class="s">}</span></code>
.</p>
<p>Parsing of the <code class="inline"><span class="c">#!</span></code>
 switches starts wherever "perl" is mentioned in the line.
The sequences "-*" and "- " are specifically ignored so that you could,
if you were so inclined, say</p>
<pre class="verbatim"><ol><li>    <span class="c">#!/bin/sh</span></li><li>    <span class="c">#! -*-perl-*-</span></li><li>    <a class="l_k" href="functions/eval.html">eval</a> <span class="q">'exec perl -x -wS $0 ${1+&quot;$@&quot;}'</span></li><li>        if <span class="n">0</span><span class="sc">;</span></li></ol></pre><p>to let Perl see the <b>-p</b> switch.</p>
<p>A similar trick involves the <i>env</i> program, if you have it.</p>
<pre class="verbatim"><ol><li>    <span class="c">#!/usr/bin/env perl</span></li></ol></pre><p>The examples above use a relative path to the perl interpreter,
getting whatever version is first in the user's path.  If you want
a specific version of Perl, say, perl5.14.1, you should place
that directly in the <code class="inline"><span class="c">#!</span></code>
 line's path.</p>
<p>If the <code class="inline"><span class="c">#!</span></code>
 line does not contain the word "perl" nor the word "indir",
the program named after the <code class="inline"><span class="c">#!</span></code>
 is executed instead of the Perl
interpreter.  This is slightly bizarre, but it helps people on machines
that don't do <code class="inline"><span class="c">#!</span></code>
, because they can tell a program that their SHELL is
<i>/usr/bin/perl</i>, and Perl will then dispatch the program to the correct
interpreter for them.</p>
<p>After locating your program, Perl compiles the entire program to an
internal form.  If there are any compilation errors, execution of the
program is not attempted.  (This is unlike the typical shell script,
which might run part-way through before finding a syntax error.)</p>
<p>If the program is syntactically correct, it is executed.  If the program
runs off the end without hitting an exit() or die() operator, an implicit
<code class="inline"><a class="l_k" href="functions/exit.html">exit(0)</a></code> is provided to indicate successful completion.</p>
<a name="%23!-and-quoting-on-non-Unix-systems"></a><h2>#! and quoting on non-Unix systems
 </h2>
<p>Unix's <code class="inline"><span class="c">#!</span></code>
 technique can be simulated on other systems:</p>
<ul>
<li><a name="OS%2f2"></a><b>OS/2</b>
<p>Put</p>
<pre class="verbatim"><ol><li>    <span class="w">extproc</span> <span class="w">perl</span> -S -<span class="w">your_switches</span></li></ol></pre><p>as the first line in <code class="inline">*.cmd</code> file (<b>-S</b> due to a bug in cmd.exe's
`extproc' handling).</p>
</li>
<li><a name="MS-DOS"></a><b>MS-DOS</b>
<p>Create a batch file to run your program, and codify it in
<code class="inline"><span class="w">ALTERNATE_SHEBANG</span></code>
 (see the <i>dosish.h</i> file in the source
distribution for more information).</p>
</li>
<li><a name="Win95%2fNT"></a><b>Win95/NT</b>
<p>The Win95/NT installation, when using the ActiveState installer for Perl,
will modify the Registry to associate the <i>.pl</i> extension with the perl
interpreter.  If you install Perl by other means (including building from
the sources), you may have to modify the Registry yourself.  Note that
this means you can no longer tell the difference between an executable
Perl program and a Perl library file.</p>
</li>
<li><a name="VMS"></a><b>VMS</b>
<p>Put</p>
<pre class="verbatim"><ol><li> <span class="i">$ perl</span> -<span class="w">mysw</span> <span class="q">&#39;f$env(&quot;procedure&quot;)&#39;</span> <span class="q">&#39;p1&#39;</span> <span class="q">&#39;p2&#39;</span> <span class="q">&#39;p3&#39;</span> <span class="q">&#39;p4&#39;</span> <span class="q">&#39;p5&#39;</span> <span class="q">&#39;p6&#39;</span> <span class="q">&#39;p7&#39;</span> <span class="q">&#39;p8&#39;</span> !</li><li> <span class="i">$ exit</span>++ + ++<span class="i">$status</span> != <span class="n">0</span> <a class="l_k" href="functions/and.html">and</a> <span class="i">$exit</span> = <span class="i">$status</span> = <a class="l_k" href="functions/undef.html">undef</a><span class="sc">;</span></li></ol></pre><p>at the top of your program, where <b>-mysw</b> are any command line switches you
want to pass to Perl.  You can now invoke the program directly, by saying
<code class="inline"><span class="w">perl</span> <span class="w">program</span></code>
, or as a DCL procedure, by saying <code class="inline"><span class="i">@program</span></code>
 (or implicitly
via <i>DCL$PATH</i> by just using the name of the program).</p>
<p>This incantation is a bit much to remember, but Perl will display it for
you if you say <code class="inline"><span class="w">perl</span> <span class="q">&quot;-V:startperl&quot;</span></code>
.</p>
</li>
</ul>
<p>Command-interpreters on non-Unix systems have rather different ideas
on quoting than Unix shells.  You'll need to learn the special
characters in your command-interpreter (<code class="inline"><span class="i">*</span></code>
, <code class="inline">\</code>
 and <code class="inline">"</code> are
common) and how to protect whitespace and these characters to run
one-liners (see <a href="#-e-commandline">-e</a> below).</p>
<p>On some systems, you may have to change single-quotes to double ones,
which you must <i>not</i> do on Unix or Plan 9 systems.  You might also
have to change a single % to a %%.</p>
<p>For example:</p>
<pre class="verbatim"><ol><li>    # Unix</li><li>    perl -e 'print "Hello world\n"'</li><li></li><li>    # MS-DOS, etc.</li><li>    perl -e "print \"Hello world\n\""</li><li></li><li>    # VMS</li><li>    perl -e "print ""Hello world\n"""</li></ol></pre><p>The problem is that none of this is reliable: it depends on the
command and it is entirely possible neither works.  If <i>4DOS</i> were
the command shell, this would probably work better:</p>
<pre class="verbatim"><ol><li>    perl -e "print &lt;Ctrl-x&gt;"Hello world\n&lt;Ctrl-x&gt;""</li></ol></pre><p><b>CMD.EXE</b> in Windows NT slipped a lot of standard Unix functionality in
when nobody was looking, but just try to find documentation for its
quoting rules.</p>
<p>There is no general solution to all of this.  It's just a mess.</p>
<a name="Location-of-Perl"></a><h2>Location of Perl
</h2>
<p>It may seem obvious to say, but Perl is useful only when users can
easily find it.  When possible, it's good for both <i>/usr/bin/perl</i>
and <i>/usr/local/bin/perl</i> to be symlinks to the actual binary.  If
that can't be done, system administrators are strongly encouraged
to put (symlinks to) perl and its accompanying utilities into a
directory typically found along a user's PATH, or in some other
obvious and convenient place.</p>
<p>In this documentation, <code class="inline">#!/usr/bin/perl</code>
 on the first line of the program
will stand in for whatever method works on your system.  You are
advised to use a specific path if you care about a specific version.</p>
<pre class="verbatim"><ol><li>    <span class="c">#!/usr/local/bin/perl5.14</span></li></ol></pre><p>or if you just want to be running at least version, place a statement
like this at the top of your program:</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/use.html">use</a> <span class="n">5.014</span><span class="sc">;</span></li></ol></pre><a name="Command-Switches"></a><h2>Command Switches
 </h2>
<p>As with all standard commands, a single-character switch may be
clustered with the following switch, if any.</p>
<pre class="verbatim"><ol><li>    <span class="c">#!/usr/bin/perl -spi.orig	# same as -s -p -i.orig</span></li></ol></pre><p>A <code class="inline">--</code>
 signals the end of options and disables further option processing. Any
arguments after the <code class="inline">--</code>
 are treated as filenames and arguments.</p>
<p>Switches include:</p>
<ul>
<li><a name="*-0*%5b_octal%2fhexadecimal_%5d"></a><b><b>-0</b>[<i>octal/hexadecimal</i>]
 </b>
<p>specifies the input record separator (<code class="inline"><span class="i">$/</span></code>
) as an octal or
hexadecimal number.  If there are no digits, the null character is the
separator.  Other switches may precede or follow the digits.  For
example, if you have a version of <i>find</i> which can print filenames
terminated by the null character, you can say this:</p>
<pre class="verbatim"><ol><li>    <span class="w">find</span> . -<span class="w">name</span> <span class="q">&#39;*.orig&#39;</span> -<span class="w">print0</span> | <span class="w">perl</span> -<span class="w">n0e</span> <a class="l_k" href="functions/unlink.html">unlink</a></li></ol></pre><p>The special value 00 will cause Perl to slurp files in paragraph mode.
Any value 0400 or above will cause Perl to slurp files whole, but by convention
the value 0777 is the one normally used for this purpose.</p>
<p>You can also specify the separator character using hexadecimal notation:
<b>-0x<i>HHH...</i></b>, where the <code class="inline"><i>H</i></code> are valid hexadecimal digits.  Unlike
the octal form, this one may be used to specify any Unicode character, even
those beyond 0xFF.  So if you <i>really</i> want a record separator of 0777,
specify it as <b>-0x1FF</b>.  (This means that you cannot use the <b>-x</b> option
with a directory name that consists of hexadecimal digits, or else Perl
will think you have specified a hex number to <b>-0</b>.)</p>
</li>
<li><a name="*-a*"></a><b><b>-a</b>
 </b>
<p>turns on autosplit mode when used with a <b>-n</b> or <b>-p</b>.  An implicit
split command to the @F array is done as the first thing inside the
implicit while loop produced by the <b>-n</b> or <b>-p</b>.</p>
<pre class="verbatim"><ol><li>    <span class="w">perl</span> -<span class="w">ane</span> <span class="q">&#39;print pop(@F), &quot;\n&quot;;&#39;</span></li></ol></pre><p>is equivalent to</p>
<pre class="verbatim"><ol><li>    while <span class="s">(</span>&lt;&gt;<span class="s">)</span> <span class="s">{</span></li><li>	<span class="i">@F</span> = <a class="l_k" href="functions/split.html">split</a><span class="s">(</span><span class="q">&#39; &#39;</span><span class="s">)</span><span class="sc">;</span></li><li>	<a class="l_k" href="functions/print.html">print</a> <a class="l_k" href="functions/pop.html">pop</a><span class="s">(</span><span class="i">@F</span><span class="s">)</span><span class="cm">,</span> <span class="q">&quot;\n&quot;</span><span class="sc">;</span></li><li>    <span class="s">}</span></li></ol></pre><p>An alternate delimiter may be specified using <b>-F</b>.</p>
<p><b>-a</b> implicitly sets <b>-n</b>.</p>
</li>
<li><a name="*-C-%5b_number%2flist_%5d*"></a><b><b>-C [<i>number/list</i>]</b>
</b>
<p>The <b>-C</b> flag controls some of the Perl Unicode features.</p>
<p>As of 5.8.1, the <b>-C</b> can be followed either by a number or a list
of option letters.  The letters, their numeric values, and effects
are as follows; listing the letters is equal to summing the numbers.</p>
<pre class="verbatim"><ol><li>    <span class="w">I</span>     <span class="n">1</span>   <span class="w">STDIN</span> <span class="w">is</span> <span class="w">assumed</span> <span class="w">to</span> <span class="w">be</span> <span class="w">in</span> <span class="w">UTF</span>-<span class="n">8</span></li><li>    <span class="w">O</span>     <span class="n">2</span>   <span class="w">STDOUT</span> <span class="w">will</span> <span class="w">be</span> <span class="w">in</span> <span class="w">UTF</span>-<span class="n">8</span></li><li>    <span class="w">E</span>     <span class="n">4</span>   <span class="w">STDERR</span> <span class="w">will</span> <span class="w">be</span> <span class="w">in</span> <span class="w">UTF</span>-<span class="n">8</span></li><li>    <span class="w">S</span>     <span class="n">7</span>   <span class="w">I</span> + <span class="w">O</span> + <span class="w">E</span></li><li>    <span class="w">i</span>     <span class="n">8</span>   <span class="w">UTF</span>-<span class="n">8</span> <span class="w">is</span> <span class="w">the</span> <span class="w">default</span> <span class="w">PerlIO</span> <span class="w">layer</span> <a class="l_k" href="functions/for.html">for</a> <span class="w">input</span> <span class="w">streams</span></li><li>    <span class="w">o</span>    <span class="n">16</span>   <span class="w">UTF</span>-<span class="n">8</span> <span class="w">is</span> <span class="w">the</span> <span class="w">default</span> <span class="w">PerlIO</span> <span class="w">layer</span> <a class="l_k" href="functions/for.html">for</a> <span class="w">output</span> <span class="w">streams</span></li><li>    <span class="w">D</span>    <span class="n">24</span>   <span class="w">i</span> + <span class="w">o</span></li><li>    <span class="w">A</span>    <span class="n">32</span>   <span class="w">the</span> <span class="i">@ARGV</span> <span class="w">elements</span> <span class="w">are</span> <span class="w">expected</span> <span class="w">to</span> <span class="w">be</span> <span class="w">strings</span> <span class="w">encoded</span></li><li>              <span class="w">in</span> <span class="w">UTF</span>-<span class="n">8</span></li><li>    <span class="w">L</span>    <span class="n">64</span>   <span class="w">normally</span> <span class="w">the</span> <span class="q">&quot;IOEioA&quot;</span> <span class="w">are</span> <span class="w">unconditional</span><span class="cm">,</span> <span class="w">the</span> <span class="w">L</span> <span class="w">makes</span></li><li>              <span class="w">them</span> <span class="w">conditional</span> <span class="w">on</span> <span class="w">the</span> <span class="w">locale</span> <span class="w">environment</span> <span class="i">variables</span></li><li>              <span class="s">(</span><span class="w">the</span> <span class="w">LC_ALL</span><span class="cm">,</span> <span class="w">LC_CTYPE</span><span class="cm">,</span> <a class="l_k" href="functions/and.html">and</a> <span class="w">LANG</span><span class="cm">,</span> <span class="w">in</span> <span class="w">the</span> <span class="w">order</span> <span class="w">of</span></li><li>              <span class="w">decreasing</span> <span class="w">precedence</span><span class="s">)</span> -- <a class="l_k" href="functions/if.html">if</a> <span class="w">the</span> <span class="w">variables</span> <span class="w">indicate</span></li><li>              <span class="w">UTF</span>-<span class="n">8</span><span class="cm">,</span> <span class="w">then</span> <span class="w">the</span> <span class="w">selected</span> <span class="q">&quot;IOEioA&quot;</span> <span class="w">are</span> <span class="w">in</span> <span class="w">effect</span></li><li>    <span class="w">a</span>   <span class="n">256</span>   <span class="w">Set</span> <span class="i">$</span>{<span class="w">^UTF8CACHE</span>} <span class="w">to</span> -<span class="n">1</span><span class="cm">,</span> <span class="w">to</span> <span class="w">run</span> <span class="w">the</span> <span class="w">UTF</span>-<span class="n">8</span> <span class="w">caching</span></li><li>              <span class="w">code</span> <span class="w">in</span> <span class="w">debugging</span> <span class="w">mode</span>.</li></ol></pre><p>For example, <b>-COE</b> and <b>-C6</b> will both turn on UTF-8-ness on both
STDOUT and STDERR.  Repeating letters is just redundant, not cumulative
nor toggling.</p>
<p>The <code class="inline"><span class="w">io</span></code>
 options mean that any subsequent open() (or similar I/O
operations) in the current file scope will have the <code class="inline"><span class="j">:</span><span class="w">utf8</span></code>
 PerlIO layer
implicitly applied to them, in other words, UTF-8 is expected from any
input stream, and UTF-8 is produced to any output stream.  This is just
the default, with explicit layers in open() and with binmode() one can
manipulate streams as usual.</p>
<p><b>-C</b> on its own (not followed by any number or option list), or the
empty string <code class="inline"><span class="q">&quot;&quot;</span></code>
 for the <code class="inline"><span class="w">PERL_UNICODE</span></code>
 environment variable, has the
same effect as <b>-CSDL</b>.  In other words, the standard I/O handles and
the default <code class="inline"><a class="l_k" href="functions/open.html">open()</a></code> layer are UTF-8-fied <i>but</i> only if the locale
environment variables indicate a UTF-8 locale.  This behaviour follows
the <i>implicit</i> (and problematic) UTF-8 behaviour of Perl 5.8.0.
(See <a href="perl581delta.html#UTF-8-no-longer-default-under-UTF-8-locales">UTF-8 no longer default under UTF-8 locales in perl581delta</a>.)</p>
<p>You can use <b>-C0</b> (or <code class="inline"><span class="q">&quot;0&quot;</span></code>
 for <code class="inline"><span class="w">PERL_UNICODE</span></code>
) to explicitly
disable all the above Unicode features.</p>
<p>The read-only magic variable <code class="inline"><span class="i">$</span>{<span class="w">^UNICODE</span>}</code>
 reflects the numeric value
of this setting.  This variable is set during Perl startup and is
thereafter read-only.  If you want runtime effects, use the three-arg
open() (see <a href="functions/open.html">open</a>), the two-arg binmode() (see <a href="functions/binmode.html">binmode</a>),
and the <code class="inline"><a class="l_k" href="functions/open.html">open</a></code> pragma (see <a href="open.html">open</a>).</p>
<p>(In Perls earlier than 5.8.1 the <b>-C</b> switch was a Win32-only switch
that enabled the use of Unicode-aware "wide system call" Win32 APIs.
This feature was practically unused, however, and the command line
switch was therefore "recycled".)</p>
<p><b>Note:</b> Since perl 5.10.1, if the <b>-C</b> option is used on the <code class="inline"><span class="c">#!</span></code>
 line,
it must be specified on the command line as well, since the standard streams
are already set up at this point in the execution of the perl interpreter.
You can also use binmode() to set the encoding of an I/O stream.</p>
</li>
<li><a name="*-c*"></a><b><b>-c</b>
</b>
<p>causes Perl to check the syntax of the program and then exit without
executing it.  Actually, it <i>will</i> execute any <code class="inline">BEGIN</code>
, <code class="inline">UNITCHECK</code>
,
or <code class="inline">CHECK</code>
 blocks and any <code class="inline"><a class="l_k" href="functions/use.html">use</a></code> statements: these are considered as
occurring outside the execution of your program.  <code class="inline">INIT</code>
 and <code class="inline">END</code>

blocks, however, will be skipped.</p>
</li>
<li><a name="*-d*"></a><b><b>-d</b>
 </b>
</li>
<li><a name="*-dt*"></a><b><b>-dt</b></b>
<p>runs the program under the Perl debugger.  See <a href="perldebug.html">perldebug</a>.
If <b>t</b> is specified, it indicates to the debugger that threads
will be used in the code being debugged.</p>
</li>
<li><a name="*-d%3a*_MOD%5b%3dbar%2cbaz%5d_"></a><b><b>-d:</b><i>MOD[=bar,baz]</i>
 </b>
</li>
<li><a name="*-dt%3a*_MOD%5b%3dbar%2cbaz%5d_"></a><b><b>-dt:</b><i>MOD[=bar,baz]</i></b>
<p>runs the program under the control of a debugging, profiling, or tracing
module installed as <code class="inline">Devel::<i>MOD</i></code>. E.g., <b>-d:DProf</b> executes the
program using the <code class="inline"><span class="w">Devel::DProf</span></code>
 profiler.  As with the <b>-M</b> flag, options
may be passed to the <code class="inline">Devel::<i>MOD</i></code> package where they will be received
and interpreted by the <code class="inline">Devel::<i>MOD</i>::import</code> routine.  Again, like <b>-M</b>,
use -<b>-d:-<i>MOD</i></b> to call <code class="inline">Devel::<i>MOD</i>::unimport</code> instead of import.  The
comma-separated list of options must follow a <code class="inline">=</code>
 character.  If <b>t</b> is
specified, it indicates to the debugger that threads will be used in the
code being debugged.  See <a href="perldebug.html">perldebug</a>.</p>
</li>
<li><a name="*-D*_letters_"></a><b><b>-D</b><i>letters</i>
  </b>
</li>
<li><a name="*-D*_number_"></a><b><b>-D</b><i>number</i></b>
<p>sets debugging flags. This switch is enabled only if your perl binary has
been built with debugging enabled: normal production perls won't have
been.</p>
<p>For example, to watch how perl executes your program, use <b>-Dtls</b>.
Another nice value is <b>-Dx</b>, which lists your compiled syntax tree, and
<b>-Dr</b> displays compiled regular expressions; the format of the output is
explained in <a href="perldebguts.html">perldebguts</a>.</p>
<p>As an alternative, specify a number instead of list of letters (e.g.,
<b>-D14</b> is equivalent to <b>-Dtls</b>):</p>
<pre class="verbatim"><ol><li>         <span class="n">1</span>  <span class="w">p</span>  <span class="w">Tokenizing</span> <a class="l_k" href="functions/and.html">and</a> <span class="w">parsing</span> <span class="s">(</span><span class="w">with</span> <span class="w">v</span><span class="cm">,</span> <span class="w">displays</span> <span class="w">parse</span></li><li>               <span class="w">stack</span><span class="s">)</span></li><li>         <span class="n">2</span>  <span class="q">s  Stack snapshots (with v, displays all stacks)</span></li><li>         <span class="q">         4  l  Context (loop) stack processing</span></li><li>         <span class="q">         8  t  Trace execution</span></li><li>        <span class="q">        16  o  Method and overloading resolution</span></li><li>        <span class="q">        32  c  String/numeric conversions</span></li><li>        <span class="q">        64  P  Print profiling info, source file input state</span></li><li>       <span class="q">       128  m  Memory and SV</span> <span class="w">allocation</span></li><li>       <span class="n">256</span>  <span class="w">f</span>  <span class="w">Format</span> <span class="w">processing</span></li><li>       <span class="n">512</span>  <span class="w">r</span>  <span class="w">Regular</span> <span class="w">expression</span> <span class="w">parsing</span> <a class="l_k" href="functions/and.html">and</a> <span class="w">execution</span></li><li>      <span class="n">1024</span>  x  <span class="w">Syntax</span> <span class="w">tree</span> <a class="l_k" href="functions/dump.html">dump</a></li><li>      <span class="n">2048</span>  <span class="w">u</span>  <span class="w">Tainting</span> <span class="w">checks</span></li><li>      <span class="n">4096</span>  <span class="w">U</span>  <span class="w">Unofficial</span><span class="cm">,</span> <span class="w">User</span> <span class="w">hacking</span> <span class="s">(</span><span class="w">reserved</span> <a class="l_k" href="functions/for.html">for</a> <span class="w">private</span><span class="cm">,</span></li><li>               <span class="w">unreleased</span> <a class="l_k" href="functions/use.html">use</a><span class="s">)</span></li><li>      <span class="n">8192</span>  <span class="w">H</span>  <span class="w">Hash</span> <a class="l_k" href="functions/dump.html">dump</a> -- <span class="w">usurps</span> <a class="l_k" href="functions/values.html">values</a><span class="s">(</span><span class="s">)</span></li><li>     <span class="n">16384</span>  <span class="w">X</span>  <span class="w">Scratchpad</span> <span class="w">allocation</span></li><li>     <span class="n">32768</span>  <span class="w">D</span>  <span class="w">Cleaning</span> <span class="w">up</span></li><li>     <span class="n">65536</span>  <span class="w">S</span>  <span class="w">Op</span> <span class="w">slab</span> <span class="w">allocation</span></li><li>    <span class="n">131072</span>  <span class="w">T</span>  <span class="w">Tokenizing</span></li><li>    <span class="n">262144</span>  <span class="w">R</span>  <span class="w">Include</span> <span class="w">reference</span> <span class="w">counts</span> <span class="w">of</span> <span class="w">dumped</span> <span class="i">variables</span></li><li>               <span class="s">(</span><span class="w">eg</span> <a class="l_k" href="functions/when.html">when</a> <span class="w">using</span> -<span class="w">Ds</span><span class="s">)</span></li><li>    <span class="n">524288</span>  <span class="w">J</span>  <span class="w">show</span> <span class="q">s,t,P-debug (don&#39;t Jump over) on opcodes within</span></li><li>               <span class="q">               package DB</span></li><li>   <span class="q">   1048576  v  Verbose: use in conjunction with other flags</span></li><li>   <span class="q">   2097152  C  Copy On Write</span></li><li>   <span class="q">   4194304  A  Consistency checks on internal structures</span></li><li>   <span class="q">   8388608  q  quiet - currently only suppresses the &quot;EXECUTING&quot;</span></li><li>               <span class="q">               message</span></li><li>  <span class="q">  16777216  M  trace smart match resolution</span></li><li>  <span class="q">  33554432  B  dump suBroutine definitions,</span> <span class="w">including</span> <span class="w">special</span></li><li>               <span class="w">Blocks</span> <span class="w">like</span> <a class="l_k" href="functions/BEGIN.html">BEGIN</a></li><li>  <span class="n">67108864</span>  <span class="w">L</span>  <span class="w">trace</span> <span class="w">Locale</span>-<span class="w">related</span> <span class="w">info</span><span class="sc">;</span> <span class="w">what</span> <span class="w">gets</span> <span class="w">output</span> <span class="w">is</span> <span class="w">very</span></li><li>               <span class="w">subject</span> <span class="w">to</span> <span class="w">change</span></li><li> <span class="n">134217728</span>  <span class="w">i</span>  <span class="w">trace</span> <span class="w">PerlIO</span> <span class="w">layer</span> <span class="w">processing</span>.  <span class="w">Set</span> <span class="w">PERLIO_DEBUG</span> <span class="w">to</span></li><li>               <span class="w">the</span> <span class="w">filename</span> <span class="w">to</span> <span class="w">trace</span> <span class="w">to</span>.</li></ol></pre><p>All these flags require <b>-DDEBUGGING</b> when you compile the Perl
executable (but see <code class="inline"><span class="j">:</span><span class="w">opd</span></code>
 in <a href="Devel/Peek.html">Devel::Peek</a> or <a href="re.html#'debug'-mode">'debug' mode in re</a>
which may change this).
See the <i>INSTALL</i> file in the Perl source distribution
for how to do this.</p>
<p>If you're just trying to get a print out of each line of Perl code
as it executes, the way that <code class="inline"><span class="w">sh</span> -x</code>
 provides for shell scripts,
you can't use Perl's <b>-D</b> switch.  Instead do this</p>
<pre class="verbatim"><ol><li>  # If you have "env" utility</li><li>  env PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS program</li><li></li><li>  # Bourne shell syntax</li><li>  $ PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS program</li><li></li><li>  # csh syntax</li><li>  % (setenv PERLDB_OPTS "NonStop=1 AutoTrace=1 frame=2"; perl -dS program)</li></ol></pre><p>See <a href="perldebug.html">perldebug</a> for details and variations.</p>
</li>
<li><a name="*-e*-_commandline_"></a><b><b>-e</b> <i>commandline</i>
</b>
<p>may be used to enter one line of program.  If <b>-e</b> is given, Perl
will not look for a filename in the argument list.  Multiple <b>-e</b>
commands may be given to build up a multi-line script.  Make sure
to use semicolons where you would in a normal program.</p>
</li>
<li><a name="*-E*-_commandline_"></a><b><b>-E</b> <i>commandline</i>
</b>
<p>behaves just like <b>-e</b>, except that it implicitly enables all
optional features (in the main compilation unit). See <a href="feature.html">feature</a>.</p>
</li>
<li><a name="*-f*"></a><b><b>-f</b>
  </b>
<p>Disable executing <i>$Config{sitelib}/sitecustomize.pl</i> at startup.</p>
<p>Perl can be built so that it by default will try to execute
<i>$Config{sitelib}/sitecustomize.pl</i> at startup (in a BEGIN block).
This is a hook that allows the sysadmin to customize how Perl behaves.
It can for instance be used to add entries to the @INC array to make Perl
find modules in non-standard locations.</p>
<p>Perl actually inserts the following code:</p>
<pre class="verbatim"><ol><li>    BEGIN <span class="s">{</span></li><li>        <a class="l_k" href="functions/do.html">do</a> <span class="s">{</span> <a class="l_k" href="functions/local.html">local</a> <span class="i">$!</span><span class="sc">;</span> -f <span class="q">&quot;$Config{sitelib}/sitecustomize.pl&quot;</span><span class="sc">;</span> <span class="s">}</span></li><li>            &amp;&amp; <a class="l_k" href="functions/do.html">do</a> <span class="q">&quot;$Config{sitelib}/sitecustomize.pl&quot;</span><span class="sc">;</span></li><li>    <span class="s">}</span></li></ol></pre><p>Since it is an actual <code class="inline"><a class="l_k" href="functions/do.html">do</a></code> (not a <code class="inline"><a class="l_k" href="functions/require.html">require</a></code>), <i>sitecustomize.pl</i>
doesn't need to return a true value. The code is run in package <code class="inline"><span class="w">main</span></code>
,
in its own lexical scope. However, if the script dies, <code class="inline"><span class="i">$@</span></code>
 will not
be set.</p>
<p>The value of <code class="inline"><span class="i">$Config</span>{<span class="w">sitelib</span>}</code>
 is also determined in C code and not
read from <code class="inline"><span class="w">Config</span>.<span class="w">pm</span></code>
, which is not loaded.</p>
<p>The code is executed <i>very</i> early. For example, any changes made to
<code class="inline"><span class="i">@INC</span></code>
 will show up in the output of `perl -V`. Of course, <code class="inline">END</code>

blocks will be likewise executed very late.</p>
<p>To determine at runtime if this capability has been compiled in your
perl, you can check the value of <code class="inline"><span class="i">$Config</span>{<span class="w">usesitecustomize</span>}</code>
.</p>
</li>
<li><a name="*-F*_pattern_"></a><b><b>-F</b><i>pattern</i>
</b>
<p>specifies the pattern to split on for <b>-a</b>. The pattern may be
surrounded by <code class="inline"><span class="q">//</span></code>
, <code class="inline"><span class="q">&quot;&quot;</span></code>
, or <code class="inline"><span class="q">&#39;&#39;</span></code>
, otherwise it will be put in single
quotes. You can't use literal whitespace or NUL characters in the pattern.</p>
<p><b>-F</b> implicitly sets both <b>-a</b> and <b>-n</b>.</p>
</li>
<li><a name="*-h*"></a><b><b>-h</b>
</b>
<p>prints a summary of the options.</p>
</li>
<li><a name="*-i*%5b_extension_%5d"></a><b><b>-i</b>[<i>extension</i>]
 </b>
<p>specifies that files processed by the <code class="inline">&lt;&gt;</code>
 construct are to be
edited in-place.  It does this by renaming the input file, opening the
output file by the original name, and selecting that output file as the
default for print() statements.  The extension, if supplied, is used to
modify the name of the old file to make a backup copy, following these
rules:</p>
<p>If no extension is supplied, and your system supports it, the original
<i>file</i> is kept open without a name while the output is redirected to
a new file with the original <i>filename</i>.  When perl exits, cleanly or not,
the original <i>file</i> is unlinked.</p>
<p>If the extension doesn't contain a <code class="inline"><span class="i">*</span></code>
, then it is appended to the
end of the current filename as a suffix.  If the extension does
contain one or more <code class="inline"><span class="i">*</span></code>
 characters, then each <code class="inline"><span class="i">*</span></code>
 is replaced
with the current filename.  In Perl terms, you could think of this
as:</p>
<pre class="verbatim"><ol><li>    <span class="s">(</span><span class="i">$backup</span> = <span class="i">$extension</span><span class="s">)</span> =~ <span class="q">s/\*/$file_name/g</span><span class="sc">;</span></li></ol></pre><p>This allows you to add a prefix to the backup file, instead of (or in
addition to) a suffix:</p>
<pre class="verbatim"><ol><li> <span class="i">$ perl</span> -<span class="w">pi&#39;orig_</span>*<span class="q">&#39; -e &#39;</span><span class="q">s/bar/baz/</span><span class="q">&#39; fileA  # backup to</span></li><li>                                           <span class="q">                                           # &#39;</span><span class="w">orig_fileA</span><span class="q">&#39;</span></li></ol></pre><p>Or even to place backup copies of the original files into another
directory (provided the directory already exists):</p>
<pre class="verbatim"><ol><li> <span class="i">$ perl</span> -<span class="w">pi&#39;old</span><span class="q">/*.orig&#39; -e &#39;s/</span><span class="w">bar</span>/<span class="w">baz</span><span class="q">/&#39; fileA  # backup to</span></li><li>                                               <span class="q">                                               # &#39;old/</span><span class="w">fileA</span>.<span class="w">orig</span><span class="q">&#39;</span></li></ol></pre><p>These sets of one-liners are equivalent:</p>
<pre class="verbatim"><ol><li> <span class="i">$ perl</span> -<span class="w">pi</span> -e <span class="q">&#39;s/bar/baz/&#39;</span> <span class="w">fileA</span>          <span class="c"># overwrite current file</span></li><li> <span class="i">$ perl</span> -<span class="w">pi</span><span class="q">&#39;*&#39;</span> -<span class="w">e</span> <span class="q">&#39;s/bar/baz/&#39;</span> <span class="w">fileA</span>       <span class="c"># overwrite current file</span></li><li></li><li> <span class="i">$ perl</span> -<span class="w">pi</span><span class="q">&#39;.orig&#39;</span> -<span class="w">e</span> <span class="q">&#39;s/bar/baz/&#39;</span> <span class="w">fileA</span>   <span class="c"># backup to &#39;fileA.orig&#39;</span></li><li> <span class="i">$ perl</span> -<span class="w">pi</span><span class="q">&#39;*.orig&#39;</span> -<span class="w">e</span> <span class="q">&#39;s/bar/baz/&#39;</span> <span class="w">fileA</span>  <span class="c"># backup to &#39;fileA.orig&#39;</span></li></ol></pre><p>From the shell, saying</p>
<pre class="verbatim"><ol><li>    <span class="i">$ perl</span> -<span class="w">p</span> -<span class="w">i</span>.<span class="w">orig</span> -e <span class="q">&quot;s/foo/bar/; ... &quot;</span></li></ol></pre><p>is the same as using the program:</p>
<pre class="verbatim"><ol><li>    <span class="c">#!/usr/bin/perl -pi.orig</span></li><li>    <span class="q">s/foo/bar/</span><span class="sc">;</span></li></ol></pre><p>which is equivalent to</p>
<pre class="verbatim"><ol><li>    <span class="c">#!/usr/bin/perl</span></li><li>    <span class="i">$extension</span> = <span class="q">&#39;.orig&#39;</span><span class="sc">;</span></li><li>    <span class="j">LINE:</span> while <span class="s">(</span>&lt;&gt;<span class="s">)</span> <span class="s">{</span></li><li>	if <span class="s">(</span><span class="i">$ARGV</span> ne <span class="i">$oldargv</span><span class="s">)</span> <span class="s">{</span></li><li>	    if <span class="s">(</span><span class="i">$extension</span> !~ <span class="q">/\*/</span><span class="s">)</span> <span class="s">{</span></li><li>		<span class="i">$backup</span> = <span class="i">$ARGV</span> . <span class="i">$extension</span><span class="sc">;</span></li><li>	    <span class="s">}</span></li><li>	    else <span class="s">{</span></li><li>		<span class="s">(</span><span class="i">$backup</span> = <span class="i">$extension</span><span class="s">)</span> =~ <span class="q">s/\*/$ARGV/g</span><span class="sc">;</span></li><li>	    <span class="s">}</span></li><li>	    <a class="l_k" href="functions/rename.html">rename</a><span class="s">(</span><span class="i">$ARGV</span><span class="cm">,</span> <span class="i">$backup</span><span class="s">)</span><span class="sc">;</span></li><li>	    <a class="l_k" href="functions/open.html">open</a><span class="s">(</span><span class="w">ARGVOUT</span><span class="cm">,</span> <span class="q">&quot;&gt;$ARGV&quot;</span><span class="s">)</span><span class="sc">;</span></li><li>	    <a class="l_k" href="functions/select.html">select</a><span class="s">(</span><span class="w">ARGVOUT</span><span class="s">)</span><span class="sc">;</span></li><li>	    <span class="i">$oldargv</span> = <span class="i">$ARGV</span><span class="sc">;</span></li><li>	<span class="s">}</span></li><li>	<span class="q">s/foo/bar/</span><span class="sc">;</span></li><li>    <span class="s">}</span></li><li>    <a class="l_k" href="functions/continue.html">continue</a> <span class="s">{</span></li><li>	<a class="l_k" href="functions/print.html">print</a><span class="sc">;</span>	<span class="c"># this prints to original filename</span></li><li>    <span class="s">}</span></li><li>    <a class="l_k" href="functions/select.html">select</a><span class="s">(</span><span class="w">STDOUT</span><span class="s">)</span><span class="sc">;</span></li></ol></pre><p>except that the <b>-i</b> form doesn't need to compare $ARGV to $oldargv to
know when the filename has changed.  It does, however, use ARGVOUT for
the selected filehandle.  Note that STDOUT is restored as the default
output filehandle after the loop.</p>
<p>As shown above, Perl creates the backup file whether or not any output
is actually changed.  So this is just a fancy way to copy files:</p>
<pre class="verbatim"><ol><li>    $ perl -p -i'/some/file/path/*' -e 1 file1 file2 file3...</li><li>or</li><li>    $ perl -p -i'.orig' -e 1 file1 file2 file3...</li></ol></pre><p>You can use <code class="inline"><a class="l_k" href="functions/eof.html">eof</a></code> without parentheses to locate the end of each input
file, in case you want to append to each file, or reset line numbering
(see example in <a href="functions/eof.html">eof</a>).</p>
<p>If, for a given file, Perl is unable to create the backup file as
specified in the extension then it will skip that file and continue on
with the next one (if it exists).</p>
<p>For a discussion of issues surrounding file permissions and <b>-i</b>, see
<a href="perlfaq5.html#Why-does-Perl-let-me-delete-read-only-files%3f-Why-does--i-clobber-protected-files%3f-Isn't-this-a-bug-in-Perl%3f">Why does Perl let me delete read-only files? Why does -i clobber protected files? Isn't this a bug in Perl? in perlfaq5</a>.</p>
<p>You cannot use <b>-i</b> to create directories or to strip extensions from
files.</p>
<p>Perl does not expand <code class="inline">~</code>
 in filenames, which is good, since some
folks use it for their backup files:</p>
<pre class="verbatim"><ol><li>    $ perl -pi~ -e 's/foo/bar/' file1 file2 file3...</li></ol></pre><p>Note that because <b>-i</b> renames or deletes the original file before
creating a new file of the same name, Unix-style soft and hard links will
not be preserved.</p>
<p>Finally, the <b>-i</b> switch does not impede execution when no
files are given on the command line.  In this case, no backup is made
(the original file cannot, of course, be determined) and processing
proceeds from STDIN to STDOUT as might be expected.</p>
</li>
<li><a name="*-I*_directory_"></a><b><b>-I</b><i>directory</i>
 </b>
<p>Directories specified by <b>-I</b> are prepended to the search path for
modules (<code class="inline"><span class="i">@INC</span></code>
).</p>
</li>
<li><a name="*-l*%5b_octnum_%5d"></a><b><b>-l</b>[<i>octnum</i>]
  </b>
<p>enables automatic line-ending processing.  It has two separate
effects.  First, it automatically chomps <code class="inline"><span class="i">$/</span></code>
 (the input record
separator) when used with <b>-n</b> or <b>-p</b>.  Second, it assigns <code class="inline"><span class="i">$\</span></code>

(the output record separator) to have the value of <i>octnum</i> so
that any print statements will have that separator added back on.
If <i>octnum</i> is omitted, sets <code class="inline"><span class="i">$\</span></code>
 to the current value of
<code class="inline"><span class="i">$/</span></code>
.  For instance, to trim lines to 80 columns:</p>
<pre class="verbatim"><ol><li>    <span class="w">perl</span> -<span class="w">lpe</span> <span class="q">&#39;substr($_, 80) = &quot;&quot;&#39;</span></li></ol></pre><p>Note that the assignment <code class="inline"><span class="i">$\</span> = <span class="i">$/</span></code>
 is done when the switch is processed,
so the input record separator can be different than the output record
separator if the <b>-l</b> switch is followed by a <b>-0</b> switch:</p>
<pre class="verbatim"><ol><li>    gnufind / -print0 | perl -ln0e 'print "found $_" if -p'</li></ol></pre><p>This sets <code class="inline"><span class="i">$\</span></code>
 to newline and then sets <code class="inline"><span class="i">$/</span></code>
 to the null character.</p>
</li>
<li><a name="*-m*%5b*-*%5d_module_"></a><b><b>-m</b>[<b>-</b>]<i>module</i>
 </b>
</li>
<li><a name="*-M*%5b*-*%5d_module_"></a><b><b>-M</b>[<b>-</b>]<i>module</i></b>
</li>
<li><a name="*-M*%5b*-*%5d_'module-...'_"></a><b><b>-M</b>[<b>-</b>]<i>'module ...'</i></b>
</li>
<li><a name="*-%5bmM%5d*%5b*-*%5d_module%3darg%5b%2carg%5d..._"></a><b><b>-[mM]</b>[<b>-</b>]<i>module=arg[,arg]...</i></b>
<p><b>-m</b><i>module</i> executes <code class="inline"><a class="l_k" href="functions/use.html">use</a></code> <i>module</i> <code class="inline"><span class="s">(</span><span class="s">)</span><span class="sc">;</span></code>
 before executing your
program.</p>
<p><b>-M</b><i>module</i> executes <code class="inline"><a class="l_k" href="functions/use.html">use</a></code> <i>module</i> <code class="inline"><span class="sc">;</span></code>
 before executing your
program.  You can use quotes to add extra code after the module name,
e.g., <code class="inline">'-M<i>MODULE</i> qw(foo bar)'</code>.</p>
<p>If the first character after the <b>-M</b> or <b>-m</b> is a dash (<b>-</b>)
then the 'use' is replaced with 'no'.</p>
<p>A little builtin syntactic sugar means you can also say
<b>-m<i>MODULE</i>=foo,bar</b> or <b>-M<i>MODULE</i>=foo,bar</b> as a shortcut for
<b>'-M<i>MODULE</i> qw(foo bar)'</b>.  This avoids the need to use quotes when
importing symbols.  The actual code generated by <b>-M<i>MODULE</i>=foo,bar</b> is
<code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">module</span> <a class="l_k" href="functions/split.html">split</a><span class="s">(</span><span class="q">/,/</span><span class="cm">,</span><span class="q">q{foo,bar}</span><span class="s">)</span></code>
.  Note that the <code class="inline">=</code>
 form
removes the distinction between <b>-m</b> and <b>-M</b>; that is,
<b>-m<i>MODULE</i>=foo,bar</b> is the same as <b>-M<i>MODULE</i>=foo,bar</b>.</p>
<p>A consequence of this is that <b>-M<i>MODULE</i>=number</b> never does a version check,
unless <code class="inline"><i>MODULE</i>::import()</code> itself is set up to do a version check, which
could happen for example if <i>MODULE</i> inherits from <a href="Exporter.html">Exporter</a>.</p>
</li>
<li><a name="*-n*"></a><b><b>-n</b>
</b>
<p>causes Perl to assume the following loop around your program, which
makes it iterate over filename arguments somewhat like <i>sed -n</i> or
<i>awk</i>:</p>
<pre class="verbatim"><ol><li>  <span class="j">LINE:</span></li><li>    while <span class="s">(</span>&lt;&gt;<span class="s">)</span> <span class="s">{</span></li><li>	...		<span class="c"># your program goes here</span></li><li>    <span class="s">}</span></li></ol></pre><p>Note that the lines are not printed by default.  See <a href="#-p">-p</a> to have
lines printed.  If a file named by an argument cannot be opened for
some reason, Perl warns you about it and moves on to the next file.</p>
<p>Also note that <code class="inline">&lt;&gt;</code>
 passes command line arguments to
<a href="functions/open.html">open</a>, which doesn't necessarily interpret them as file names.
See  <a href="perlop.html">perlop</a> for possible security implications.</p>
<p>Here is an efficient way to delete all files that haven't been modified for
at least a week:</p>
<pre class="verbatim"><ol><li>    <span class="w">find</span> . -<span class="w">mtime</span> +<span class="n">7</span> -<a class="l_k" href="functions/print.html">print</a> | <span class="w">perl</span> -<span class="w">nle</span> <a class="l_k" href="functions/unlink.html">unlink</a></li></ol></pre><p>This is faster than using the <b>-exec</b> switch of <i>find</i> because you don't
have to start a process on every filename found (but it's not faster
than using the <b>-delete</b> switch available in newer versions of <i>find</i>.
It does suffer from the bug of mishandling newlines in pathnames, which
you can fix if you follow the example under <b>-0</b>.</p>
<p><code class="inline">BEGIN</code>
 and <code class="inline">END</code>
 blocks may be used to capture control before or after
the implicit program loop, just as in <i>awk</i>.</p>
</li>
<li><a name="*-p*"></a><b><b>-p</b>
</b>
<p>causes Perl to assume the following loop around your program, which
makes it iterate over filename arguments somewhat like <i>sed</i>:</p>
<pre class="verbatim"><ol><li>  <span class="j">LINE:</span></li><li>    while <span class="s">(</span>&lt;&gt;<span class="s">)</span> <span class="s">{</span></li><li>	...		<span class="c"># your program goes here</span></li><li>    <span class="s">}</span> <a class="l_k" href="functions/continue.html">continue</a> <span class="s">{</span></li><li>	<a class="l_k" href="functions/print.html">print</a> or <a class="l_k" href="functions/die.html">die</a> <span class="q">&quot;-p destination: $!\n&quot;</span><span class="sc">;</span></li><li>    <span class="s">}</span></li></ol></pre><p>If a file named by an argument cannot be opened for some reason, Perl
warns you about it, and moves on to the next file.  Note that the
lines are printed automatically.  An error occurring during printing is
treated as fatal.  To suppress printing use the <b>-n</b> switch.  A <b>-p</b>
overrides a <b>-n</b> switch.</p>
<p><code class="inline">BEGIN</code>
 and <code class="inline">END</code>
 blocks may be used to capture control before or after
the implicit loop, just as in <i>awk</i>.</p>
</li>
<li><a name="*-s*"></a><b><b>-s</b>
</b>
<p>enables rudimentary switch parsing for switches on the command
line after the program name but before any filename arguments (or before
an argument of <b>--</b>).  Any switch found there is removed from @ARGV and sets the
corresponding variable in the Perl program.  The following program
prints "1" if the program is invoked with a <b>-xyz</b> switch, and "abc"
if it is invoked with <b>-xyz=abc</b>.</p>
<pre class="verbatim"><ol><li>    <span class="c">#!/usr/bin/perl -s</span></li><li>    if <span class="s">(</span><span class="i">$xyz</span><span class="s">)</span> <span class="s">{</span> <a class="l_k" href="functions/print.html">print</a> <span class="q">&quot;$xyz\n&quot;</span> <span class="s">}</span></li></ol></pre><p>Do note that a switch like <b>--help</b> creates the variable <code class="inline"><span class="i">$</span>{-<span class="w">help</span>}</code>
, which is
not compliant with <code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">strict</span> <span class="q">&quot;refs&quot;</span></code>
.  Also, when using this option on a
script with warnings enabled you may get a lot of spurious "used only once"
warnings.</p>
</li>
<li><a name="*-S*"></a><b><b>-S</b>
</b>
<p>makes Perl use the PATH environment variable to search for the
program unless the name of the program contains path separators.</p>
<p>On some platforms, this also makes Perl append suffixes to the
filename while searching for it.  For example, on Win32 platforms,
the ".bat" and ".cmd" suffixes are appended if a lookup for the
original name fails, and if the name does not already end in one
of those suffixes.  If your Perl was compiled with <code class="inline"><span class="w">DEBUGGING</span></code>
 turned
on, using the <b>-Dp</b> switch to Perl shows how the search progresses.</p>
<p>Typically this is used to emulate <code class="inline"><span class="c">#!</span></code>
 startup on platforms that don't
support <code class="inline"><span class="c">#!</span></code>
.  It's also convenient when debugging a script that uses <code class="inline"><span class="c">#!</span></code>
,
and is thus normally found by the shell's $PATH search mechanism.</p>
<p>This example works on many platforms that have a shell compatible with
Bourne shell:</p>
<pre class="verbatim"><ol><li>    <span class="c">#!/usr/bin/perl</span></li><li>    <a class="l_k" href="functions/eval.html">eval</a> <span class="q">&#39;exec /usr/bin/perl -wS $0 ${1+&quot;$@&quot;}&#39;</span></li><li>	    if <span class="i">$running_under_some_shell</span><span class="sc">;</span></li></ol></pre><p>The system ignores the first line and feeds the program to <i>/bin/sh</i>,
which proceeds to try to execute the Perl program as a shell script.
The shell executes the second line as a normal shell command, and thus
starts up the Perl interpreter.  On some systems $0 doesn't always
contain the full pathname, so the <b>-S</b> tells Perl to search for the
program if necessary.  After Perl locates the program, it parses the
lines and ignores them because the variable $running_under_some_shell
is never true.  If the program will be interpreted by csh, you will need
to replace <code class="inline"><span class="i">$</span>{<span class="n">1</span>+<span class="q">&quot;$@&quot;</span>}</code>
 with <code class="inline"><span class="i">$*</span></code>
, even though that doesn't understand
embedded spaces (and such) in the argument list.  To start up <i>sh</i> rather
than <i>csh</i>, some systems may have to replace the <code class="inline"><span class="c">#!</span></code>
 line with a line
containing just a colon, which will be politely ignored by Perl.  Other
systems can't control that, and need a totally devious construct that
will work under any of <i>csh</i>, <i>sh</i>, or Perl, such as the following:</p>
<pre class="verbatim"><ol><li>	<a class="l_k" href="functions/eval.html">eval</a> <span class="q">&#39;(exit $?0)&#39;</span> &amp;&amp; <a class="l_k" href="functions/eval.html">eval</a> <span class="q">&#39;exec perl -wS $0 ${1+&quot;$@&quot;}&#39;</span></li><li>	&amp; <a class="l_k" href="functions/eval.html">eval</a> <span class="q">&#39;exec /usr/bin/perl -wS $0 $argv:q&#39;</span></li><li>		if <span class="i">$running_under_some_shell</span><span class="sc">;</span></li></ol></pre><p>If the filename supplied contains directory separators (and so is an
absolute or relative pathname), and if that file is not found,
platforms that append file extensions will do so and try to look
for the file with those extensions added, one by one.</p>
<p>On DOS-like platforms, if the program does not contain directory
separators, it will first be searched for in the current directory
before being searched for on the PATH.  On Unix platforms, the
program will be searched for strictly on the PATH.</p>
</li>
<li><a name="*-t*"></a><b><b>-t</b>
</b>
<p>Like <b>-T</b>, but taint checks will issue warnings rather than fatal
errors.  These warnings can now be controlled normally with <code class="inline"><a class="l_k" href="functions/no.html">no</a> <span class="w">warnings</span>
<span class="q">qw(taint)</span></code>
.</p>
<p><b>Note: This is not a substitute for <code class="inline">-T</code>
!</b> This is meant to be
used <i>only</i> as a temporary development aid while securing legacy code:
for real production code and for new secure code written from scratch,
always use the real <b>-T</b>.</p>
</li>
<li><a name="*-T*"></a><b><b>-T</b>
</b>
<p>turns on "taint" so you can test them.  Ordinarily
these checks are done only when running setuid or setgid.  It's a
good idea to turn them on explicitly for programs that run on behalf
of someone else whom you might not necessarily trust, such as CGI
programs or any internet servers you might write in Perl.  See
<a href="perlsec.html">perlsec</a> for details.  For security reasons, this option must be
seen by Perl quite early; usually this means it must appear early
on the command line or in the <code class="inline"><span class="c">#!</span></code>
 line for systems which support
that construct.</p>
</li>
<li><a name="*-u*"></a><b><b>-u</b>
</b>
<p>This switch causes Perl to dump core after compiling your
program.  You can then in theory take this core dump and turn it
into an executable file by using the <i>undump</i> program (not supplied).
This speeds startup at the expense of some disk space (which you
can minimize by stripping the executable).  (Still, a "hello world"
executable comes out to about 200K on my machine.)  If you want to
execute a portion of your program before dumping, use the dump()
operator instead.  Note: availability of <i>undump</i> is platform
specific and may not be available for a specific port of Perl.</p>
</li>
<li><a name="*-U*"></a><b><b>-U</b>
</b>
<p>allows Perl to do unsafe operations.  Currently the only "unsafe"
operations are attempting to unlink directories while running as superuser
and running setuid programs with fatal taint checks turned into warnings.
Note that warnings must be enabled along with this option to actually
<i>generate</i> the taint-check warnings.</p>
</li>
<li><a name="*-v*"></a><b><b>-v</b>
</b>
<p>prints the version and patchlevel of your perl executable.</p>
</li>
<li><a name="*-V*"></a><b><b>-V</b>
</b>
<p>prints summary of the major perl configuration values and the current
values of @INC.</p>
</li>
<li><a name="*-V%3a*_configvar_"></a><b><b>-V:</b><i>configvar</i></b>
<p>Prints to STDOUT the value of the named configuration variable(s),
with multiples when your <code class="inline"><i>configvar</i></code> argument looks like a regex (has
non-letters).  For example:</p>
<pre class="verbatim"><ol><li>    $ perl -V:libc</li><li>	libc='/lib/libc-2.2.4.so';</li><li>    $ perl -V:lib.</li><li>	libs='-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc';</li><li>	libc='/lib/libc-2.2.4.so';</li><li>    $ perl -V:lib.*</li><li>	libpth='/usr/local/lib /lib /usr/lib';</li><li>	libs='-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc';</li><li>	lib_ext='.a';</li><li>	libc='/lib/libc-2.2.4.so';</li><li>	libperl='libperl.a';</li><li>	....</li></ol></pre><p>Additionally, extra colons can be used to control formatting.  A
trailing colon suppresses the linefeed and terminator ";", allowing
you to embed queries into shell commands.  (mnemonic: PATH separator
":".)</p>
<pre class="verbatim"><ol><li>    $ echo "compression-vars: " `perl -V:z.*: ` " are here !"</li><li>    compression-vars:  zcat='' zip='zip'  are here !</li></ol></pre><p>A leading colon removes the "name=" part of the response, this allows
you to map to the name you need.  (mnemonic: empty label)</p>
<pre class="verbatim"><ol><li>    $ echo "goodvfork="`./perl -Ilib -V::usevfork`</li><li>    goodvfork=false;</li></ol></pre><p>Leading and trailing colons can be used together if you need
positional parameter values without the names.  Note that in the case
below, the <code class="inline"><span class="w">PERL_API</span></code>
 params are returned in alphabetical order.</p>
<pre class="verbatim"><ol><li>    $ echo building_on `perl -V::osname: -V::PERL_API_.*:` now</li><li>    building_on 'linux' '5' '1' '9' now</li></ol></pre></li>
<li><a name="*-w*"></a><b><b>-w</b>
</b>
<p>prints warnings about dubious constructs, such as variable names
mentioned only once and scalar variables used
before being set; redefined subroutines; references to undefined
filehandles; filehandles opened read-only that you are attempting
to write on; values used as a number that don't <i>look</i> like numbers;
using an array as though it were a scalar; if your subroutines
recurse more than 100 deep; and innumerable other things.</p>
<p>This switch really just enables the global <code class="inline"><span class="i">$^W</span></code>
 variable; normally,
the lexically scoped <code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">warnings</span></code>
 pragma is preferred. You
can disable or promote into fatal errors specific warnings using
<code class="inline"><span class="w">__WARN__</span></code>
 hooks, as described in <a href="perlvar.html">perlvar</a> and <a href="functions/warn.html">warn</a>.
See also <a href="perldiag.html">perldiag</a> and <a href="perltrap.html">perltrap</a>.  A fine-grained warning
facility is also available if you want to manipulate entire classes
of warnings; see <a href="warnings.html">warnings</a>.</p>
</li>
<li><a name="*-W*"></a><b><b>-W</b>
</b>
<p>Enables all warnings regardless of <code class="inline"><a class="l_k" href="functions/no.html">no</a> <span class="w">warnings</span></code>
 or <code class="inline"><span class="i">$^W</span></code>
.
See <a href="warnings.html">warnings</a>.</p>
</li>
<li><a name="*-X*"></a><b><b>-X</b>
</b>
<p>Disables all warnings regardless of <code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">warnings</span></code>
 or <code class="inline"><span class="i">$^W</span></code>
.
See <a href="warnings.html">warnings</a>.</p>
</li>
<li><a name="*-x*"></a><b><b>-x</b>
</b>
</li>
<li><a name="*-x*_directory_"></a><b><b>-x</b><i>directory</i></b>
<p>tells Perl that the program is embedded in a larger chunk of unrelated
text, such as in a mail message.  Leading garbage will be
discarded until the first line that starts with <code class="inline"><span class="c">#!</span></code>
 and contains the
string "perl".  Any meaningful switches on that line will be applied.</p>
<p>All references to line numbers by the program (warnings, errors, ...)
will treat the <code class="inline"><span class="c">#!</span></code>
 line as the first line.
Thus a warning on the 2nd line of the program, which is on the 100th
line in the file will be reported as line 2, not as line 100.
This can be overridden by using the <code class="inline"><span class="c">#line</span></code>
 directive.
(See <a href="perlsyn.html#Plain-Old-Comments-(Not!)">Plain Old Comments (Not!) in perlsyn</a>)</p>
<p>If a directory name is specified, Perl will switch to that directory
before running the program.  The <b>-x</b> switch controls only the
disposal of leading garbage.  The program must be terminated with
<code class="inline"><a name="__END__"></a>__END__</code>
 if there is trailing garbage to be ignored;  the program
can process any or all of the trailing garbage via the <code class="inline"><span class="w">DATA</span></code>
 filehandle
if desired.</p>
<p>The directory, if specified, must appear immediately following the <b>-x</b>
with no intervening whitespace.</p>
</li>
</ul>
<a name="ENVIRONMENT"></a><h1>ENVIRONMENT
</h1>
<ul>
<li><a name="HOME"></a><b>HOME
</b>
<p>Used if <code class="inline"><a class="l_k" href="functions/chdir.html">chdir</a></code> has no argument.</p>
</li>
<li><a name="LOGDIR"></a><b>LOGDIR
</b>
<p>Used if <code class="inline"><a class="l_k" href="functions/chdir.html">chdir</a></code> has no argument and HOME is not set.</p>
</li>
<li><a name="PATH"></a><b>PATH
</b>
<p>Used in executing subprocesses, and in finding the program if <b>-S</b> is
used.</p>
</li>
<li><a name="PERL5LIB"></a><b>PERL5LIB
</b>
<p>A list of directories in which to look for Perl library
files before looking in the standard library and the current
directory.  Any architecture-specific and version-specific directories,
such as <i>version/archname/</i>, <i>version/</i>, or <i>archname/</i> under the
specified locations are automatically included if they exist, with this
lookup done at interpreter startup time.  In addition, any directories
matching the entries in <code class="inline"><span class="i">$Config</span>{<span class="w">inc_version_list</span>}</code>
 are added.
(These typically would be for older compatible perl versions installed
in the same directory tree.)</p>
<p>If PERL5LIB is not defined, PERLLIB is used.  Directories are separated
(like in PATH) by a colon on Unixish platforms and by a semicolon on
Windows (the proper path separator being given by the command <code class="inline">perl
-V:<i>path_sep</i></code>).</p>
<p>When running taint checks, either because the program was running setuid or
setgid, or the <b>-T</b> or <b>-t</b> switch was specified, neither PERL5LIB nor
PERLLIB is consulted. The program should instead say:</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/use.html">use</a> <span class="w">lib</span> <span class="q">&quot;/my/directory&quot;</span><span class="sc">;</span></li></ol></pre></li>
<li><a name="PERL5OPT"></a><b>PERL5OPT
</b>
<p>Command-line options (switches).  Switches in this variable are treated
as if they were on every Perl command line.  Only the <b>-[CDIMUdmtwW]</b>
switches are allowed.  When running taint checks (either because the
program was running setuid or setgid, or because the <b>-T</b> or <b>-t</b>
switch was used), this variable is ignored.  If PERL5OPT begins with
<b>-T</b>, tainting will be enabled and subsequent options ignored.  If
PERL5OPT begins with <b>-t</b>, tainting will be enabled, a writable dot
removed from @INC, and subsequent options honored.</p>
</li>
<li><a name="PERLIO"></a><b>PERLIO
</b>
<p>A space (or colon) separated list of PerlIO layers. If perl is built
to use PerlIO system for IO (the default) these layers affect Perl's IO.</p>
<p>It is conventional to start layer names with a colon (for example, <code class="inline"><span class="j">:</span><span class="w">perlio</span></code>
) to
emphasize their similarity to variable "attributes". But the code that parses
layer specification strings, which is also used to decode the PERLIO
environment variable, treats the colon as a separator.</p>
<p>An unset or empty PERLIO is equivalent to the default set of layers for
your platform; for example, <code class="inline">:unix:perlio</code> on Unix-like systems
and <code class="inline">:unix:crlf</code> on Windows and other DOS-like systems.</p>
<p>The list becomes the default for <i>all</i> Perl's IO. Consequently only built-in
layers can appear in this list, as external layers (such as <code class="inline"><span class="j">:</span><span class="i">encoding</span><span class="s">(</span><span class="s">)</span></code>
) need
IO in order to load them!  See <a href="open.html">open pragma</a> for how to add external
encodings as defaults.</p>
<p>Layers it makes sense to include in the PERLIO environment
variable are briefly summarized below. For more details see <a href="PerlIO.html">PerlIO</a>.</p>
<ul>
<li><a name="%3abytes"></a><b>:bytes
</b>
<p>A pseudolayer that turns the <code class="inline"><span class="j">:</span><span class="w">utf8</span></code>
 flag <i>off</i> for the layer below;
unlikely to be useful on its own in the global PERLIO environment variable.
You perhaps were thinking of <code class="inline">:crlf:bytes</code> or <code class="inline">:perlio:bytes</code>.</p>
</li>
<li><a name="%3acrlf"></a><b>:crlf
</b>
<p>A layer which does CRLF to <code class="inline"><span class="q">&quot;\n&quot;</span></code>
 translation distinguishing "text" and
"binary" files in the manner of MS-DOS and similar operating systems.
(It currently does <i>not</i> mimic MS-DOS as far as treating of Control-Z
as being an end-of-file marker.)</p>
</li>
<li><a name="%3ammap"></a><b>:mmap
</b>
<p>A layer that implements "reading" of files by using <i>mmap</i>(2) to
make an entire file appear in the process's address space, and then
using that as PerlIO's "buffer".</p>
</li>
<li><a name="%3aperlio"></a><b>:perlio
</b>
<p>This is a re-implementation of stdio-like buffering written as a
PerlIO layer.  As such it will call whatever layer is below it for
its operations, typically <code class="inline"><span class="j">:</span><span class="w">unix</span></code>
.</p>
</li>
<li><a name="%3apop"></a><b>:pop
</b>
<p>An experimental pseudolayer that removes the topmost layer.
Use with the same care as is reserved for nitroglycerine.</p>
</li>
<li><a name="%3araw"></a><b>:raw
</b>
<p>A pseudolayer that manipulates other layers.  Applying the <code class="inline"><span class="j">:</span><span class="w">raw</span></code>

layer is equivalent to calling <code class="inline"><a class="l_k" href="functions/binmode.html">binmode($fh)</a></code>.  It makes the stream
pass each byte as-is without translation.  In particular, both CRLF
translation and intuiting <code class="inline"><span class="j">:</span><span class="w">utf8</span></code>
 from the locale are disabled.</p>
<p>Unlike in earlier versions of Perl, <code class="inline"><span class="j">:</span><span class="w">raw</span></code>
 is <i>not</i>
just the inverse of <code class="inline"><span class="j">:</span><span class="w">crlf</span></code>
: other layers which would affect the
binary nature of the stream are also removed or disabled.</p>
</li>
<li><a name="%3astdio"></a><b>:stdio
</b>
<p>This layer provides a PerlIO interface by wrapping system's ANSI C "stdio"
library calls. The layer provides both buffering and IO.
Note that the <code class="inline"><span class="j">:</span><span class="w">stdio</span></code>
 layer does <i>not</i> do CRLF translation even if that
is the platform's normal behaviour. You will need a <code class="inline"><span class="j">:</span><span class="w">crlf</span></code>
 layer above it
to do that.</p>
</li>
<li><a name="%3aunix"></a><b>:unix
</b>
<p>Low-level layer that calls <code class="inline"><a class="l_k" href="functions/read.html">read</a></code>, <code class="inline"><a class="l_k" href="functions/write.html">write</a></code>, <code class="inline"><span class="w">lseek</span></code>
, etc.</p>
</li>
<li><a name="%3autf8"></a><b>:utf8
</b>
<p>A pseudolayer that enables a flag in the layer below to tell Perl
that output should be in utf8 and that input should be regarded as
already in valid utf8 form. <b>WARNING: It does not check for validity and as such
should be handled with extreme caution for input, because security violations
can occur with non-shortest UTF-8 encodings, etc.</b> Generally <code class="inline"><span class="j">:</span><span class="i">encoding</span><span class="s">(</span><span class="w">UTF</span>-<span class="n">8</span><span class="s">)</span></code>
 is
the best option when reading UTF-8 encoded data.</p>
</li>
<li><a name="%3awin32"></a><b>:win32
</b>
<p>On Win32 platforms this <i>experimental</i> layer uses native "handle" IO
rather than a Unix-like numeric file descriptor layer. Known to be
buggy in this release (5.14).</p>
</li>
</ul>
<p>The default set of layers should give acceptable results on all platforms</p>
<p>For Unix platforms that will be the equivalent of "unix perlio" or "stdio".
Configure is set up to prefer the "stdio" implementation if the system's library
provides for fast access to the buffer; otherwise, it uses the "unix perlio"
implementation.</p>
<p>On Win32 the default in this release (5.14) is "unix crlf". Win32's "stdio"
has a number of bugs/mis-features for Perl IO which are somewhat depending
on the version and vendor of the C compiler. Using our own <code class="inline"><span class="w">crlf</span></code>
 layer as
the buffer avoids those issues and makes things more uniform.  The <code class="inline"><span class="w">crlf</span></code>

layer provides CRLF conversion as well as buffering.</p>
<p>This release (5.14) uses <code class="inline"><span class="w">unix</span></code>
 as the bottom layer on Win32, and so still
uses the C compiler's numeric file descriptor routines. There is an
experimental native <code class="inline"><span class="w">win32</span></code>
 layer, which is expected to be enhanced and
should eventually become the default under Win32.</p>
<p>The PERLIO environment variable is completely ignored when Perl
is run in taint mode.</p>
</li>
<li><a name="PERLIO_DEBUG"></a><b>PERLIO_DEBUG
</b>
<p>If set to the name of a file or device when Perl is run with the
<b>-Di</b> command-line switch, the logging of certain operations of
the PerlIO subsystem will be redirected to the specified file rather
than going to stderr, which is the default. The file is opened in append
mode. Typical uses are in Unix:</p>
<pre class="verbatim"><ol><li>   <span class="i">% env</span> <span class="w">PERLIO_DEBUG</span>=<span class="q">/tmp/perlio</span>.<a class="l_k" href="functions/log.html">log</a> <span class="w">perl</span> -<span class="w">Di</span> <span class="w">script</span> ...</li></ol></pre><p>and under Win32, the approximately equivalent:</p>
<pre class="verbatim"><ol><li>   &gt; <span class="w">set</span> <span class="w">PERLIO_DEBUG</span>=<span class="w">CON</span></li><li>   <span class="w">perl</span> -<span class="w">Di</span> <span class="w">script</span> ...</li></ol></pre><p>This functionality is disabled for setuid scripts, for scripts run
with <b>-T</b>, and for scripts run on a Perl built without <code class="inline">-<span class="w">DDEBUGGING</span></code>

support.</p>
</li>
<li><a name="PERLLIB"></a><b>PERLLIB
</b>
<p>A list of directories in which to look for Perl library
files before looking in the standard library and the current directory.
If PERL5LIB is defined, PERLLIB is not used.</p>
<p>The PERLLIB environment variable is completely ignored when Perl
is run in taint mode.</p>
</li>
<li><a name="PERL5DB"></a><b>PERL5DB
</b>
<p>The command used to load the debugger code.  The default is:</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;perl5db.pl&quot;</span> <span class="s">}</span></li></ol></pre><p>The PERL5DB environment variable is only used when Perl is started with
a bare <b>-d</b> switch.</p>
</li>
<li><a name="PERL5DB_THREADED"></a><b>PERL5DB_THREADED
</b>
<p>If set to a true value, indicates to the debugger that the code being
debugged uses threads.</p>
</li>
<li><a name="PERL5SHELL-(specific-to-the-Win32-port)"></a><b>PERL5SHELL (specific to the Win32 port)
</b>
<p>On Win32 ports only, may be set to an alternative shell that Perl must use
internally for executing "backtick" commands or system().  Default is
<code class="inline"><span class="w">cmd</span>.<span class="w">exe</span> /<span class="w">x</span><span class="q">/d/c</span></code>
 on WindowsNT and <code class="inline"><span class="w">command</span>.<span class="w">com</span> /<span class="w">c</span></code>
 on Windows95.  The
value is considered space-separated.  Precede any character that
needs to be protected, like a space or backslash, with another backslash.</p>
<p>Note that Perl doesn't use COMSPEC for this purpose because
COMSPEC has a high degree of variability among users, leading to
portability concerns.  Besides, Perl can use a shell that may not be
fit for interactive use, and setting COMSPEC to such a shell may
interfere with the proper functioning of other programs (which usually
look in COMSPEC to find a shell fit for interactive use).</p>
<p>Before Perl 5.10.0 and 5.8.8, PERL5SHELL was not taint checked
when running external commands.  It is recommended that
you explicitly set (or delete) <code class="inline"><span class="i">$ENV</span>{<span class="w">PERL5SHELL</span>}</code>
 when running
in taint mode under Windows.</p>
</li>
<li><a name="PERL_ALLOW_NON_IFS_LSP-(specific-to-the-Win32-port)"></a><b>PERL_ALLOW_NON_IFS_LSP (specific to the Win32 port)
</b>
<p>Set to 1 to allow the use of non-IFS compatible LSPs (Layered Service Providers).
Perl normally searches for an IFS-compatible LSP because this is required
for its emulation of Windows sockets as real filehandles.  However, this may
cause problems if you have a firewall such as <i>McAfee Guardian</i>, which requires
that all applications use its LSP but which is not IFS-compatible, because clearly
Perl will normally avoid using such an LSP.</p>
<p>Setting this environment variable to 1 means that Perl will simply use the
first suitable LSP enumerated in the catalog, which keeps <i>McAfee Guardian</i>
happy--and in that particular case Perl still works too because <i>McAfee
Guardian</i>'s LSP actually plays other games which allow applications
requiring IFS compatibility to work.</p>
</li>
<li><a name="PERL_DEBUG_MSTATS"></a><b>PERL_DEBUG_MSTATS
</b>
<p>Relevant only if Perl is compiled with the <code class="inline"><span class="w">malloc</span></code>
 included with the Perl
distribution; that is, if <code class="inline">perl -V:d_mymalloc</code> is "define".</p>
<p>If set, this dumps out memory statistics after execution.  If set
to an integer greater than one, also dumps out memory statistics
after compilation.</p>
</li>
<li><a name="PERL_DESTRUCT_LEVEL"></a><b>PERL_DESTRUCT_LEVEL
</b>
<p>Relevant only if your Perl executable was built with <b>-DDEBUGGING</b>,
this controls the behaviour of global destruction of objects and other
references.  See <a href="perlhacktips.html#PERL_DESTRUCT_LEVEL">PERL_DESTRUCT_LEVEL in perlhacktips</a> for more information.</p>
</li>
<li><a name="PERL_DL_NONLAZY"></a><b>PERL_DL_NONLAZY
</b>
<p>Set to <code class="inline"><span class="q">&quot;1&quot;</span></code>
 to have Perl resolve <i>all</i> undefined symbols when it loads
a dynamic library.  The default behaviour is to resolve symbols when
they are used.  Setting this variable is useful during testing of
extensions, as it ensures that you get an error on misspelled function
names even if the test suite doesn't call them.</p>
</li>
<li><a name="PERL_ENCODING"></a><b>PERL_ENCODING
</b>
<p>If using the <code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">encoding</span></code>
 pragma without an explicit encoding name, the
PERL_ENCODING environment variable is consulted for an encoding name.</p>
</li>
<li><a name="PERL_HASH_SEED"></a><b>PERL_HASH_SEED
</b>
<p>(Since Perl 5.8.1, new semantics in Perl 5.18.0)  Used to override
the randomization of Perl's internal hash function. The value is expressed
in hexadecimal, and may include a leading 0x. Truncated patterns
are treated as though they are suffixed with sufficient 0's as required.</p>
<p>If the option is provided, and <code class="inline"><span class="w">PERL_PERTURB_KEYS</span></code>
 is NOT set, then
a value of '0' implies <code class="inline"><span class="w">PERL_PERTURB_KEYS</span>=<span class="n">0</span></code>
 and any other value
implies <code class="inline"><span class="w">PERL_PERTURB_KEYS</span>=<span class="n">2</span></code>
.</p>
<p><b>PLEASE NOTE: The hash seed is sensitive information</b>. Hashes are
randomized to protect against local and remote attacks against Perl
code. By manually setting a seed, this protection may be partially or
completely lost.</p>
<p>See <a href="perlsec.html#Algorithmic-Complexity-Attacks">Algorithmic Complexity Attacks in perlsec</a>, <a href="#PERL_PERTURB_KEYS">PERL_PERTURB_KEYS</a>, and
<a href="#PERL_HASH_SEED_DEBUG">PERL_HASH_SEED_DEBUG</a> for more information.</p>
</li>
<li><a name="PERL_PERTURB_KEYS"></a><b>PERL_PERTURB_KEYS
</b>
<p>(Since Perl 5.18.0)  Set to <code class="inline"><span class="q">&quot;0&quot;</span></code>
 or <code class="inline"><span class="q">&quot;NO&quot;</span></code>
 then traversing keys
will be repeatable from run to run for the same PERL_HASH_SEED.
Insertion into a hash will not change the order, except to provide
for more space in the hash. When combined with setting PERL_HASH_SEED
this mode is as close to pre 5.18 behavior as you can get.</p>
<p>When set to <code class="inline"><span class="q">&quot;1&quot;</span></code>
 or <code class="inline"><span class="q">&quot;RANDOM&quot;</span></code>
 then traversing keys will be randomized.
Every time a hash is inserted into the key order will change in a random
fashion. The order may not be repeatable in a following program run
even if the PERL_HASH_SEED has been specified. This is the default
mode for perl.</p>
<p>When set to <code class="inline"><span class="q">&quot;2&quot;</span></code>
 or <code class="inline"><span class="q">&quot;DETERMINISTIC&quot;</span></code>
 then inserting keys into a hash
will cause the key order to change, but in a way that is repeatable
from program run to program run.</p>
<p><b>NOTE:</b> Use of this option is considered insecure, and is intended only
for debugging non-deterministic behavior in Perl's hash function. Do
not use it in production.</p>
<p>See <a href="perlsec.html#Algorithmic-Complexity-Attacks">Algorithmic Complexity Attacks in perlsec</a> and <a href="#PERL_HASH_SEED">PERL_HASH_SEED</a>
and <a href="#PERL_HASH_SEED_DEBUG">PERL_HASH_SEED_DEBUG</a> for more information. You can get and set the
key traversal mask for a specific hash by using the <code class="inline"><span class="i">hash_traversal_mask</span><span class="s">(</span><span class="s">)</span></code>

function from <a href="Hash/Util.html">Hash::Util</a>.</p>
</li>
<li><a name="PERL_HASH_SEED_DEBUG"></a><b>PERL_HASH_SEED_DEBUG
</b>
<p>(Since Perl 5.8.1.)  Set to <code class="inline"><span class="q">&quot;1&quot;</span></code>
 to display (to STDERR) information
about the hash function, seed, and what type of key traversal
randomization is in effect at the beginning of execution.  This, combined
with <a href="#PERL_HASH_SEED">PERL_HASH_SEED</a> and <a href="#PERL_PERTURB_KEYS">PERL_PERTURB_KEYS</a> is intended to aid in
debugging nondeterministic behaviour caused by hash randomization.</p>
<p><b>Note</b> that any information about the hash function, especially the hash
seed is <b>sensitive information</b>: by knowing it, one can craft a denial-of-service
attack against Perl code, even remotely; see <a href="perlsec.html#Algorithmic-Complexity-Attacks">Algorithmic Complexity Attacks in perlsec</a>
for more information. <b>Do not disclose the hash seed</b> to people who
don't need to know it. See also <code class="inline"><span class="i">hash_seed</span><span class="s">(</span><span class="s">)</span></code>
 and
<code class="inline"><span class="i">key_traversal_mask</span><span class="s">(</span><span class="s">)</span></code>
 in <a href="Hash/Util.html">Hash::Util</a>.</p>
<p>An example output might be:</p>
<pre class="verbatim"><ol><li> <span class="w">HASH_FUNCTION</span> = <span class="w">ONE_AT_A_TIME_HARD</span> <span class="w">HASH_SEED</span> = <span class="n">0x652e9b9349a7a032</span> <span class="w">PERTURB_KEYS</span> = <span class="n">1</span> <span class="s">(</span><span class="w">RANDOM</span><span class="s">)</span></li></ol></pre></li>
<li><a name="PERL_MEM_LOG"></a><b>PERL_MEM_LOG
</b>
<p>If your Perl was configured with <b>-Accflags=-DPERL_MEM_LOG</b>, setting
the environment variable <code class="inline"><span class="w">PERL_MEM_LOG</span></code>
 enables logging debug
messages. The value has the form <code class="inline">&lt;<i>number</i>&gt;[m][s][t]</code>, where
<code class="inline"><i>number</i></code> is the file descriptor number you want to write to (2 is
default), and the combination of letters specifies that you want
information about (m)emory and/or (s)v, optionally with
(t)imestamps. For example, <code class="inline">PERL_MEM_LOG=1mst</code> logs all
information to stdout. You can write to other opened file descriptors
in a variety of ways:</p>
<pre class="verbatim"><ol><li>  <span class="i">$ 3</span>&gt;<span class="w">foo3</span> <span class="w">PERL_MEM_LOG</span>=<span class="n">3</span><span class="q">m perl ...</span></li></ol></pre></li>
<li><a name="PERL_ROOT-(specific-to-the-VMS-port)"></a><b>PERL_ROOT (specific to the VMS port)
</b>
<p>A translation-concealed rooted logical name that contains Perl and the
logical device for the @INC path on VMS only.  Other logical names that
affect Perl on VMS include PERLSHR, PERL_ENV_TABLES, and
SYS$TIMEZONE_DIFFERENTIAL, but are optional and discussed further in
<a href="perlvms.html">perlvms</a> and in <i>README.vms</i> in the Perl source distribution.</p>
</li>
<li><a name="PERL_SIGNALS"></a><b>PERL_SIGNALS
</b>
<p>Available in Perls 5.8.1 and later.  If set to <code class="inline"><span class="q">&quot;unsafe&quot;</span></code>
, the pre-Perl-5.8.0
signal behaviour (which is immediate but unsafe) is restored.  If set
to <code class="inline"><span class="w">safe</span></code>
, then safe (but deferred) signals are used.  See
<a href="perlipc.html#Deferred-Signals-(Safe-Signals)">Deferred Signals (Safe Signals) in perlipc</a>.</p>
</li>
<li><a name="PERL_UNICODE"></a><b>PERL_UNICODE
</b>
<p>Equivalent to the <b>-C</b> command-line switch.  Note that this is not
a boolean variable. Setting this to <code class="inline"><span class="q">&quot;1&quot;</span></code>
 is not the right way to
"enable Unicode" (whatever that would mean).  You can use <code class="inline"><span class="q">&quot;0&quot;</span></code>
 to
"disable Unicode", though (or alternatively unset PERL_UNICODE in
your shell before starting Perl).  See the description of the <b>-C</b>
switch for more information.</p>
</li>
<li><a name="PERL_USE_UNSAFE_INC"></a><b>PERL_USE_UNSAFE_INC
</b>
<p>If perl has been configured to not have the current directory in
<a href="perlvar.html#%40INC">@INC </a> by default, this variable can be set to <code class="inline"><span class="q">&quot;1&quot;</span></code>

to reinstate it.  It's primarily intended for use while building and
testing modules that have not been updated to deal with "." not being in
<code class="inline"><span class="i">@INC</span></code>
 and should not be set in the environment for day-to-day use.</p>
</li>
<li><a name="SYS%24LOGIN-(specific-to-the-VMS-port)"></a><b>SYS$LOGIN (specific to the VMS port)
</b>
<p>Used if chdir has no argument and HOME and LOGDIR are not set.</p>
</li>
</ul>
<p>Perl also has environment variables that control how Perl handles data
specific to particular natural languages; see <a href="perllocale.html">perllocale</a>.</p>
<p>Perl and its various modules and components, including its test frameworks,
may sometimes make use of certain other environment variables.  Some of
these are specific to a particular platform.  Please consult the
appropriate module documentation and any documentation for your platform
(like <a href="perlsolaris.html">perlsolaris</a>, <a href="perllinux.html">perllinux</a>, <a href="perlmacosx.html">perlmacosx</a>, <a href="perlwin32.html">perlwin32</a>, etc) for
variables peculiar to those specific situations.</p>
<p>Perl makes all environment variables available to the program being
executed, and passes these along to any child processes it starts.
However, programs running setuid would do well to execute the following
lines before doing anything else, just to keep people honest:</p>
<pre class="verbatim"><ol><li>    <span class="i">$ENV</span>{<span class="w">PATH</span>}  = <span class="q">&quot;/bin:/usr/bin&quot;</span><span class="sc">;</span>    <span class="c"># or whatever you need</span></li><li>    <span class="i">$ENV</span>{<span class="w">SHELL</span>} = <span class="q">&quot;/bin/sh&quot;</span> if <a class="l_k" href="functions/exists.html">exists</a> <span class="i">$ENV</span>{<span class="w">SHELL</span>}<span class="sc">;</span></li><li>    <a class="l_k" href="functions/delete.html">delete</a> <span class="i">@ENV</span>{<span class="q">qw(IFS CDPATH ENV BASH_ENV)</span>}<span class="sc">;</span></li></ol></pre>



  <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="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><ul><li><a href="#%23!-and-quoting-on-non-Unix-systems">#! and quoting on non-Unix systems
 </a><li><a href="#Location-of-Perl">Location of Perl
</a><li><a href="#Command-Switches">Command Switches
 </a></ul><li><a href="#ENVIRONMENT">ENVIRONMENT
</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    = 'perlrun';
  perldoc.pageAddress = 'perlrun.html';
  perldoc.contentPage = 1;
  explorePerl.render();
  explorePerl.addEvents('explore_anchor');
</script>
    
  </body>
</html>