-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathperl5004delta.html
1410 lines (920 loc) · 73.7 KB
/
perl5004delta.html
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
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>perl5004delta - what's new for perl5.004</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:[email protected]" />
</head>
<body>
<ul id="index">
<li><a href="#NAME">NAME</a></li>
<li><a href="#DESCRIPTION">DESCRIPTION</a></li>
<li><a href="#Supported-Environments">Supported Environments</a></li>
<li><a href="#Core-Changes">Core Changes</a>
<ul>
<li><a href="#List-assignment-to-ENV-works">List assignment to %ENV works</a></li>
<li><a href="#Change-to-Cant-locate-Foo.pm-in-INC-error">Change to "Can't locate Foo.pm in @INC" error</a></li>
<li><a href="#Compilation-option:-Binary-compatibility-with-5.003">Compilation option: Binary compatibility with 5.003</a></li>
<li><a href="#PERL5OPT-environment-variable">$PERL5OPT environment variable</a></li>
<li><a href="#Limitations-on--M--m-and--T-options">Limitations on -M, -m, and -T options</a></li>
<li><a href="#More-precise-warnings">More precise warnings</a></li>
<li><a href="#Deprecated:-Inherited-AUTOLOAD-for-non-methods">Deprecated: Inherited AUTOLOAD for non-methods</a></li>
<li><a href="#Previously-deprecated-OVERLOAD-is-no-longer-usable">Previously deprecated %OVERLOAD is no longer usable</a></li>
<li><a href="#Subroutine-arguments-created-only-when-theyre-modified">Subroutine arguments created only when they're modified</a></li>
<li><a href="#Group-vector-changeable-with">Group vector changeable with $)</a></li>
<li><a href="#Fixed-parsing-of-digit-digit-etc">Fixed parsing of $$<digit>, &$<digit>, etc.</a></li>
<li><a href="#Fixed-localization-of-digit-etc">Fixed localization of $<digit>, $&, etc.</a></li>
<li><a href="#No-resetting-of-.-on-implicit-close">No resetting of $. on implicit close</a></li>
<li><a href="#wantarray-may-return-undef">wantarray may return undef</a></li>
<li><a href="#eval-EXPR-determines-value-of-EXPR-in-scalar-context">eval EXPR determines value of EXPR in scalar context</a></li>
<li><a href="#Changes-to-tainting-checks">Changes to tainting checks</a></li>
<li><a href="#New-Opcode-module-and-revised-Safe-module">New Opcode module and revised Safe module</a></li>
<li><a href="#Embedding-improvements">Embedding improvements</a></li>
<li><a href="#Internal-change:-FileHandle-class-based-on-IO::-classes">Internal change: FileHandle class based on IO::* classes</a></li>
<li><a href="#Internal-change:-PerlIO-abstraction-interface">Internal change: PerlIO abstraction interface</a></li>
<li><a href="#New-and-changed-syntax">New and changed syntax</a></li>
<li><a href="#New-and-changed-builtin-constants">New and changed builtin constants</a></li>
<li><a href="#New-and-changed-builtin-variables">New and changed builtin variables</a></li>
<li><a href="#New-and-changed-builtin-functions">New and changed builtin functions</a></li>
<li><a href="#New-builtin-methods">New builtin methods</a></li>
<li><a href="#TIEHANDLE-now-supported">TIEHANDLE now supported</a></li>
<li><a href="#Malloc-enhancements">Malloc enhancements</a></li>
<li><a href="#Miscellaneous-efficiency-enhancements">Miscellaneous efficiency enhancements</a></li>
</ul>
</li>
<li><a href="#Support-for-More-Operating-Systems">Support for More Operating Systems</a>
<ul>
<li><a href="#Win32">Win32</a></li>
<li><a href="#Plan-9">Plan 9</a></li>
<li><a href="#QNX">QNX</a></li>
<li><a href="#AmigaOS">AmigaOS</a></li>
</ul>
</li>
<li><a href="#Pragmata">Pragmata</a></li>
<li><a href="#Modules">Modules</a>
<ul>
<li><a href="#Required-Updates">Required Updates</a></li>
<li><a href="#Installation-directories">Installation directories</a></li>
<li><a href="#Module-information-summary">Module information summary</a></li>
<li><a href="#Fcntl">Fcntl</a></li>
<li><a href="#IO">IO</a></li>
<li><a href="#Math::Complex">Math::Complex</a></li>
<li><a href="#Math::Trig">Math::Trig</a></li>
<li><a href="#DB_File">DB_File</a></li>
<li><a href="#Net::Ping">Net::Ping</a></li>
<li><a href="#Object-oriented-overrides-for-builtin-operators">Object-oriented overrides for builtin operators</a></li>
</ul>
</li>
<li><a href="#Utility-Changes">Utility Changes</a>
<ul>
<li><a href="#pod2html">pod2html</a></li>
<li><a href="#xsubpp">xsubpp</a></li>
</ul>
</li>
<li><a href="#C-Language-API-Changes">C Language API Changes</a></li>
<li><a href="#Documentation-Changes">Documentation Changes</a></li>
<li><a href="#New-Diagnostics">New Diagnostics</a></li>
<li><a href="#BUGS">BUGS</a></li>
<li><a href="#SEE-ALSO">SEE ALSO</a></li>
<li><a href="#HISTORY">HISTORY</a></li>
</ul>
<h1 id="NAME">NAME</h1>
<p>perl5004delta - what's new for perl5.004</p>
<h1 id="DESCRIPTION">DESCRIPTION</h1>
<p>This document describes differences between the 5.003 release (as documented in <i>Programming Perl</i>, second edition--the Camel Book) and this one.</p>
<h1 id="Supported-Environments">Supported Environments</h1>
<p>Perl5.004 builds out of the box on Unix, Plan 9, LynxOS, VMS, OS/2, QNX, AmigaOS, and Windows NT. Perl runs on Windows 95 as well, but it cannot be built there, for lack of a reasonable command interpreter.</p>
<h1 id="Core-Changes">Core Changes</h1>
<p>Most importantly, many bugs were fixed, including several security problems. See the <i>Changes</i> file in the distribution for details.</p>
<h2 id="List-assignment-to-ENV-works">List assignment to %ENV works</h2>
<p><code>%ENV = ()</code> and <code>%ENV = @list</code> now work as expected (except on VMS where it generates a fatal error).</p>
<h2 id="Change-to-Cant-locate-Foo.pm-in-INC-error">Change to "Can't locate Foo.pm in @INC" error</h2>
<p>The error "Can't locate Foo.pm in @INC" now lists the contents of @INC for easier debugging.</p>
<h2 id="Compilation-option:-Binary-compatibility-with-5.003">Compilation option: Binary compatibility with 5.003</h2>
<p>There is a new Configure question that asks if you want to maintain binary compatibility with Perl 5.003. If you choose binary compatibility, you do not have to recompile your extensions, but you might have symbol conflicts if you embed Perl in another application, just as in the 5.003 release. By default, binary compatibility is preserved at the expense of symbol table pollution.</p>
<h2 id="PERL5OPT-environment-variable">$PERL5OPT environment variable</h2>
<p>You may now put Perl options in the $PERL5OPT environment variable. Unless Perl is running with taint checks, it will interpret this variable as if its contents had appeared on a "#!perl" line at the beginning of your script, except that hyphens are optional. PERL5OPT may only be used to set the following switches: <b>-[DIMUdmw]</b>.</p>
<h2 id="Limitations-on--M--m-and--T-options">Limitations on <b>-M</b>, <b>-m</b>, and <b>-T</b> options</h2>
<p>The <code>-M</code> and <code>-m</code> options are no longer allowed on the <code>#!</code> line of a script. If a script needs a module, it should invoke it with the <code>use</code> pragma.</p>
<p>The <b>-T</b> option is also forbidden on the <code>#!</code> line of a script, unless it was present on the Perl command line. Due to the way <code>#!</code> works, this usually means that <b>-T</b> must be in the first argument. Thus:</p>
<pre><code> #!/usr/bin/perl -T -w</code></pre>
<p>will probably work for an executable script invoked as <code>scriptname</code>, while:</p>
<pre><code> #!/usr/bin/perl -w -T</code></pre>
<p>will probably fail under the same conditions. (Non-Unix systems will probably not follow this rule.) But <code>perl scriptname</code> is guaranteed to fail, since then there is no chance of <b>-T</b> being found on the command line before it is found on the <code>#!</code> line.</p>
<h2 id="More-precise-warnings">More precise warnings</h2>
<p>If you removed the <b>-w</b> option from your Perl 5.003 scripts because it made Perl too verbose, we recommend that you try putting it back when you upgrade to Perl 5.004. Each new perl version tends to remove some undesirable warnings, while adding new warnings that may catch bugs in your scripts.</p>
<h2 id="Deprecated:-Inherited-AUTOLOAD-for-non-methods">Deprecated: Inherited <code>AUTOLOAD</code> for non-methods</h2>
<p>Before Perl 5.004, <code>AUTOLOAD</code> functions were looked up as methods (using the <code>@ISA</code> hierarchy), even when the function to be autoloaded was called as a plain function (e.g. <code>Foo::bar()</code>), not a method (e.g. <code>Foo->bar()</code> or <code>$obj->bar()</code>).</p>
<p>Perl 5.005 will use method lookup only for methods' <code>AUTOLOAD</code>s. However, there is a significant base of existing code that may be using the old behavior. So, as an interim step, Perl 5.004 issues an optional warning when a non-method uses an inherited <code>AUTOLOAD</code>.</p>
<p>The simple rule is: Inheritance will not work when autoloading non-methods. The simple fix for old code is: In any module that used to depend on inheriting <code>AUTOLOAD</code> for non-methods from a base class named <code>BaseClass</code>, execute <code>*AUTOLOAD = \&BaseClass::AUTOLOAD</code> during startup.</p>
<h2 id="Previously-deprecated-OVERLOAD-is-no-longer-usable">Previously deprecated %OVERLOAD is no longer usable</h2>
<p>Using %OVERLOAD to define overloading was deprecated in 5.003. Overloading is now defined using the overload pragma. %OVERLOAD is still used internally but should not be used by Perl scripts. See <a href="/cperl/lib/overload.html">overload</a> for more details.</p>
<h2 id="Subroutine-arguments-created-only-when-theyre-modified">Subroutine arguments created only when they're modified</h2>
<p>In Perl 5.004, nonexistent array and hash elements used as subroutine parameters are brought into existence only if they are actually assigned to (via <code>@_</code>).</p>
<p>Earlier versions of Perl vary in their handling of such arguments. Perl versions 5.002 and 5.003 always brought them into existence. Perl versions 5.000 and 5.001 brought them into existence only if they were not the first argument (which was almost certainly a bug). Earlier versions of Perl never brought them into existence.</p>
<p>For example, given this code:</p>
<pre><code> undef @a; undef %a;
sub show { print $_[0] };
sub change { $_[0]++ };
show($a[2]);
change($a{b});</code></pre>
<p>After this code executes in Perl 5.004, $a{b} exists but $a[2] does not. In Perl 5.002 and 5.003, both $a{b} and $a[2] would have existed (but $a[2]'s value would have been undefined).</p>
<h2 id="Group-vector-changeable-with">Group vector changeable with <code>$)</code></h2>
<p>The <code>$)</code> special variable has always (well, in Perl 5, at least) reflected not only the current effective group, but also the group list as returned by the <code>getgroups()</code> C function (if there is one). However, until this release, there has not been a way to call the <code>setgroups()</code> C function from Perl.</p>
<p>In Perl 5.004, assigning to <code>$)</code> is exactly symmetrical with examining it: The first number in its string value is used as the effective gid; if there are any numbers after the first one, they are passed to the <code>setgroups()</code> C function (if there is one).</p>
<h2 id="Fixed-parsing-of-digit-digit-etc">Fixed parsing of $$<digit>, &$<digit>, etc.</h2>
<p>Perl versions before 5.004 misinterpreted any type marker followed by "$" and a digit. For example, "$$0" was incorrectly taken to mean "${$}0" instead of "${$0}". This bug is (mostly) fixed in Perl 5.004.</p>
<p>However, the developers of Perl 5.004 could not fix this bug completely, because at least two widely-used modules depend on the old meaning of "$$0" in a string. So Perl 5.004 still interprets "$$<digit>" in the old (broken) way inside strings; but it generates this message as a warning. And in Perl 5.005, this special treatment will cease.</p>
<h2 id="Fixed-localization-of-digit-etc">Fixed localization of $<digit>, $&, etc.</h2>
<p>Perl versions before 5.004 did not always properly localize the regex-related special variables. Perl 5.004 does localize them, as the documentation has always said it should. This may result in $1, $2, etc. no longer being set where existing programs use them.</p>
<h2 id="No-resetting-of-.-on-implicit-close">No resetting of $. on implicit close</h2>
<p>The documentation for Perl 5.0 has always stated that <code>$.</code> is <i>not</i> reset when an already-open file handle is reopened with no intervening call to <code>close</code>. Due to a bug, perl versions 5.000 through 5.003 <i>did</i> reset <code>$.</code> under that circumstance; Perl 5.004 does not.</p>
<h2 id="wantarray-may-return-undef"><code>wantarray</code> may return undef</h2>
<p>The <code>wantarray</code> operator returns true if a subroutine is expected to return a list, and false otherwise. In Perl 5.004, <code>wantarray</code> can also return the undefined value if a subroutine's return value will not be used at all, which allows subroutines to avoid a time-consuming calculation of a return value if it isn't going to be used.</p>
<h2 id="eval-EXPR-determines-value-of-EXPR-in-scalar-context"><code>eval EXPR</code> determines value of EXPR in scalar context</h2>
<p>Perl (version 5) used to determine the value of EXPR inconsistently, sometimes incorrectly using the surrounding context for the determination. Now, the value of EXPR (before being parsed by eval) is always determined in a scalar context. Once parsed, it is executed as before, by providing the context that the scope surrounding the eval provided. This change makes the behavior Perl4 compatible, besides fixing bugs resulting from the inconsistent behavior. This program:</p>
<pre><code> @a = qw(time now is time);
print eval @a;
print '|', scalar eval @a;</code></pre>
<p>used to print something like "timenowis881399109|4", but now (and in perl4) prints "4|4".</p>
<h2 id="Changes-to-tainting-checks">Changes to tainting checks</h2>
<p>A bug in previous versions may have failed to detect some insecure conditions when taint checks are turned on. (Taint checks are used in setuid or setgid scripts, or when explicitly turned on with the <code>-T</code> invocation option.) Although it's unlikely, this may cause a previously-working script to now fail, which should be construed as a blessing since that indicates a potentially-serious security hole was just plugged.</p>
<p>The new restrictions when tainting include:</p>
<dl>
<dt id="No-glob-or">No glob() or <*></dt>
<dd>
<p>These operators may spawn the C shell (csh), which cannot be made safe. This restriction will be lifted in a future version of Perl when globbing is implemented without the use of an external program.</p>
</dd>
<dt id="No-spawning-if-tainted-CDPATH-ENV-BASH_ENV">No spawning if tainted $CDPATH, $ENV, $BASH_ENV</dt>
<dd>
<p>These environment variables may alter the behavior of spawned programs (especially shells) in ways that subvert security. So now they are treated as dangerous, in the manner of $IFS and $PATH.</p>
</dd>
<dt id="No-spawning-if-tainted-TERM-doesnt-look-like-a-terminal-name">No spawning if tainted $TERM doesn't look like a terminal name</dt>
<dd>
<p>Some termcap libraries do unsafe things with $TERM. However, it would be unnecessarily harsh to treat all $TERM values as unsafe, since only shell metacharacters can cause trouble in $TERM. So a tainted $TERM is considered to be safe if it contains only alphanumerics, underscores, dashes, and colons, and unsafe if it contains other characters (including whitespace).</p>
</dd>
</dl>
<h2 id="New-Opcode-module-and-revised-Safe-module">New Opcode module and revised Safe module</h2>
<p>A new Opcode module supports the creation, manipulation and application of opcode masks. The revised Safe module has a new API and is implemented using the new Opcode module. Please read the new Opcode and Safe documentation.</p>
<h2 id="Embedding-improvements">Embedding improvements</h2>
<p>In older versions of Perl it was not possible to create more than one Perl interpreter instance inside a single process without leaking like a sieve and/or crashing. The bugs that caused this behavior have all been fixed. However, you still must take care when embedding Perl in a C program. See the updated perlembed manpage for tips on how to manage your interpreters.</p>
<h2 id="Internal-change:-FileHandle-class-based-on-IO::-classes">Internal change: FileHandle class based on IO::* classes</h2>
<p>File handles are now stored internally as type IO::Handle. The FileHandle module is still supported for backwards compatibility, but it is now merely a front end to the IO::* modules, specifically IO::Handle, IO::Seekable, and IO::File. We suggest, but do not require, that you use the IO::* modules in new code.</p>
<p>In harmony with this change, <code>*GLOB{FILEHANDLE}</code> is now just a backward-compatible synonym for <code>*GLOB{IO}</code>.</p>
<h2 id="Internal-change:-PerlIO-abstraction-interface">Internal change: PerlIO abstraction interface</h2>
<p>It is now possible to build Perl with AT&T's sfio IO package instead of stdio. See <a href="/cperl/perlapio.html">perlapio</a> for more details, and the <i>INSTALL</i> file for how to use it.</p>
<h2 id="New-and-changed-syntax">New and changed syntax</h2>
<dl>
<dt id="coderef--PARAMS">$coderef->(PARAMS)</dt>
<dd>
<p>A subroutine reference may now be suffixed with an arrow and a (possibly empty) parameter list. This syntax denotes a call of the referenced subroutine, with the given parameters (if any).</p>
<p>This new syntax follows the pattern of <span style="white-space: nowrap;"><code>$hashref->{FOO}</code></span> and <span style="white-space: nowrap;"><code>$aryref->[$foo]</code></span>: You may now write <span style="white-space: nowrap;"><code>&$subref($foo)</code></span> as <span style="white-space: nowrap;"><code>$subref->($foo)</code></span>. All these arrow terms may be chained; thus, <span style="white-space: nowrap;"><code>&{$table->{FOO}}($bar)</code></span> may now be written <span style="white-space: nowrap;"><code>$table->{FOO}->($bar)</code></span>.</p>
</dd>
</dl>
<h2 id="New-and-changed-builtin-constants">New and changed builtin constants</h2>
<dl>
<dt id="PACKAGE__">__PACKAGE__</dt>
<dd>
<p>The current package name at compile time, or the undefined value if there is no current package (due to a <code>package;</code> directive). Like <code>__FILE__</code> and <code>__LINE__</code>, <code>__PACKAGE__</code> does <i>not</i> interpolate into strings.</p>
</dd>
</dl>
<h2 id="New-and-changed-builtin-variables">New and changed builtin variables</h2>
<dl>
<dt id="E">$^E</dt>
<dd>
<p>Extended error message on some platforms. (Also known as $EXTENDED_OS_ERROR if you <code>use English</code>).</p>
</dd>
<dt id="H">$^H</dt>
<dd>
<p>The current set of syntax checks enabled by <code>use strict</code>. See the documentation of <code>strict</code> for more details. Not actually new, but newly documented. Because it is intended for internal use by Perl core components, there is no <code>use English</code> long name for this variable.</p>
</dd>
<dt id="M">$^M</dt>
<dd>
<p>By default, running out of memory it is not trappable. However, if compiled for this, Perl may use the contents of <code>$^M</code> as an emergency pool after die()ing with this message. Suppose that your Perl were compiled with -DPERL_EMERGENCY_SBRK and used Perl's malloc. Then</p>
<pre><code> $^M = 'a' x (1<<16);</code></pre>
<p>would allocate a 64K buffer for use when in emergency. See the <i>INSTALL</i> file for information on how to enable this option. As a disincentive to casual use of this advanced feature, there is no <code>use English</code> long name for this variable.</p>
</dd>
</dl>
<h2 id="New-and-changed-builtin-functions">New and changed builtin functions</h2>
<dl>
<dt id="delete-on-slices">delete on slices</dt>
<dd>
<p>This now works. (e.g. <code>delete @ENV{'PATH', 'MANPATH'}</code>)</p>
</dd>
<dt id="flock">flock</dt>
<dd>
<p>is now supported on more platforms, prefers fcntl to lockf when emulating, and always flushes before (un)locking.</p>
</dd>
<dt id="printf-and-sprintf">printf and sprintf</dt>
<dd>
<p>Perl now implements these functions itself; it doesn't use the C library function sprintf() any more, except for floating-point numbers, and even then only known flags are allowed. As a result, it is now possible to know which conversions and flags will work, and what they will do.</p>
<p>The new conversions in Perl's sprintf() are:</p>
<pre><code> %i a synonym for %d
%p a pointer (the address of the Perl value, in hexadecimal)
%n special: *stores* the number of characters output so far
into the next variable in the parameter list </code></pre>
<p>The new flags that go between the <code>%</code> and the conversion are:</p>
<pre><code> # prefix octal with "0", hex with "0x"
h interpret integer as C type "short" or "unsigned short"
V interpret integer as Perl's standard integer type</code></pre>
<p>Also, where a number would appear in the flags, an asterisk ("*") may be used instead, in which case Perl uses the next item in the parameter list as the given number (that is, as the field width or precision). If a field width obtained through "*" is negative, it has the same effect as the '-' flag: left-justification.</p>
<p>See <a href="/cperl/perlfunc.html#sprintf">"sprintf" in perlfunc</a> for a complete list of conversion and flags.</p>
</dd>
<dt id="keys-as-an-lvalue">keys as an lvalue</dt>
<dd>
<p>As an lvalue, <code>keys</code> allows you to increase the number of hash buckets allocated for the given hash. This can gain you a measure of efficiency if you know the hash is going to get big. (This is similar to pre-extending an array by assigning a larger number to $#array.) If you say</p>
<pre><code> keys %hash = 200;</code></pre>
<p>then <code>%hash</code> will have at least 200 buckets allocated for it. These buckets will be retained even if you do <code>%hash = ()</code>; use <code>undef %hash</code> if you want to free the storage while <code>%hash</code> is still in scope. You can't shrink the number of buckets allocated for the hash using <code>keys</code> in this way (but you needn't worry about doing this by accident, as trying has no effect).</p>
</dd>
<dt id="my-in-Control-Structures">my() in Control Structures</dt>
<dd>
<p>You can now use my() (with or without the parentheses) in the control expressions of control structures such as:</p>
<pre><code> while (defined(my $line = <>)) {
$line = lc $line;
} continue {
print $line;
}
if ((my $answer = <STDIN>) =~ /^y(es)?$/i) {
user_agrees();
} elsif ($answer =~ /^n(o)?$/i) {
user_disagrees();
} else {
chomp $answer;
die "`$answer' is neither `yes' nor `no'";
}</code></pre>
<p>Also, you can declare a foreach loop control variable as lexical by preceding it with the word "my". For example, in:</p>
<pre><code> foreach my $i (1, 2, 3) {
some_function();
}</code></pre>
<p>$i is a lexical variable, and the scope of $i extends to the end of the loop, but not beyond it.</p>
<p>Note that you still cannot use my() on global punctuation variables such as $_ and the like.</p>
</dd>
<dt id="pack-and-unpack">pack() and unpack()</dt>
<dd>
<p>A new format 'w' represents a BER compressed integer (as defined in ASN.1). Its format is a sequence of one or more bytes, each of which provides seven bits of the total value, with the most significant first. Bit eight of each byte is set, except for the last byte, in which bit eight is clear.</p>
<p>If 'p' or 'P' are given undef as values, they now generate a NULL pointer.</p>
<p>Both pack() and unpack() now fail when their templates contain invalid types. (Invalid types used to be ignored.)</p>
</dd>
<dt id="sysseek">sysseek()</dt>
<dd>
<p>The new sysseek() operator is a variant of seek() that sets and gets the file's system read/write position, using the lseek(2) system call. It is the only reliable way to seek before using sysread() or syswrite(). Its return value is the new position, or the undefined value on failure.</p>
</dd>
<dt id="use-VERSION">use VERSION</dt>
<dd>
<p>If the first argument to <code>use</code> is a number, it is treated as a version number instead of a module name. If the version of the Perl interpreter is less than VERSION, then an error message is printed and Perl exits immediately. Because <code>use</code> occurs at compile time, this check happens immediately during the compilation process, unlike <code>require VERSION</code>, which waits until runtime for the check. This is often useful if you need to check the current Perl version before <code>use</code>ing library modules which have changed in incompatible ways from older versions of Perl. (We try not to do this more than we have to.)</p>
</dd>
<dt id="use-Module-VERSION-LIST">use Module VERSION LIST</dt>
<dd>
<p>If the VERSION argument is present between Module and LIST, then the <code>use</code> will call the VERSION method in class Module with the given version as an argument. The default VERSION method, inherited from the UNIVERSAL class, croaks if the given version is larger than the value of the variable $Module::VERSION. (Note that there is not a comma after VERSION!)</p>
<p>This version-checking mechanism is similar to the one currently used in the Exporter module, but it is faster and can be used with modules that don't use the Exporter. It is the recommended method for new code.</p>
</dd>
<dt id="prototype-FUNCTION">prototype(FUNCTION)</dt>
<dd>
<p>Returns the prototype of a function as a string (or <code>undef</code> if the function has no prototype). FUNCTION is a reference to or the name of the function whose prototype you want to retrieve. (Not actually new; just never documented before.)</p>
</dd>
<dt id="srand">srand</dt>
<dd>
<p>The default seed for <code>srand</code>, which used to be <code>time</code>, has been changed. Now it's a heady mix of difficult-to-predict system-dependent values, which should be sufficient for most everyday purposes.</p>
<p>Previous to version 5.004, calling <code>rand</code> without first calling <code>srand</code> would yield the same sequence of random numbers on most or all machines. Now, when perl sees that you're calling <code>rand</code> and haven't yet called <code>srand</code>, it calls <code>srand</code> with the default seed. You should still call <code>srand</code> manually if your code might ever be run on a pre-5.004 system, of course, or if you want a seed other than the default.</p>
</dd>
<dt id="as-Default">$_ as Default</dt>
<dd>
<p>Functions documented in the Camel to default to $_ now in fact do, and all those that do are so documented in <a href="/cperl/perlfunc.html">perlfunc</a>.</p>
</dd>
<dt id="m-gc-does-not-reset-search-position-on-failure"><code>m//gc</code> does not reset search position on failure</dt>
<dd>
<p>The <code>m//g</code> match iteration construct has always reset its target string's search position (which is visible through the <code>pos</code> operator) when a match fails; as a result, the next <code>m//g</code> match after a failure starts again at the beginning of the string. With Perl 5.004, this reset may be disabled by adding the "c" (for "continue") modifier, i.e. <code>m//gc</code>. This feature, in conjunction with the <code>\G</code> zero-width assertion, makes it possible to chain matches together. See <a href="/cperl/perlop.html">perlop</a> and <a href="/cperl/perlre.html">perlre</a>.</p>
</dd>
<dt id="m-x-ignores-whitespace-before"><code>m//x</code> ignores whitespace before ?*+{}</dt>
<dd>
<p>The <code>m//x</code> construct has always been intended to ignore all unescaped whitespace. However, before Perl 5.004, whitespace had the effect of escaping repeat modifiers like "*" or "?"; for example, <code>/a *b/x</code> was (mis)interpreted as <code>/a\*b/x</code>. This bug has been fixed in 5.004.</p>
</dd>
<dt id="nested-sub-closures-work-now">nested <code>sub{}</code> closures work now</dt>
<dd>
<p>Prior to the 5.004 release, nested anonymous functions didn't work right. They do now.</p>
</dd>
<dt id="formats-work-right-on-changing-lexicals">formats work right on changing lexicals</dt>
<dd>
<p>Just like anonymous functions that contain lexical variables that change (like a lexical index variable for a <code>foreach</code> loop), formats now work properly. For example, this silently failed before (printed only zeros), but is fine now:</p>
<pre><code> my $i;
foreach $i ( 1 .. 10 ) {
write;
}
format =
my i is @#
$i
.</code></pre>
<p>However, it still fails (without a warning) if the foreach is within a subroutine:</p>
<pre><code> my $i;
sub foo {
foreach $i ( 1 .. 10 ) {
write;
}
}
foo;
format =
my i is @#
$i
.</code></pre>
</dd>
</dl>
<h2 id="New-builtin-methods">New builtin methods</h2>
<p>The <code>UNIVERSAL</code> package automatically contains the following methods that are inherited by all other classes:</p>
<dl>
<dt id="isa-CLASS">isa(CLASS)</dt>
<dd>
<p><code>isa</code> returns <i>true</i> if its object is blessed into a subclass of <code>CLASS</code></p>
<p><code>isa</code> is also exportable and can be called as a sub with two arguments. This allows the ability to check what a reference points to. Example:</p>
<pre><code> use UNIVERSAL qw(isa);
if(isa($ref, 'ARRAY')) {
...
}</code></pre>
</dd>
<dt id="can-METHOD">can(METHOD)</dt>
<dd>
<p><code>can</code> checks to see if its object has a method called <code>METHOD</code>, if it does then a reference to the sub is returned; if it does not then <i>undef</i> is returned.</p>
</dd>
<dt id="VERSION-NEED">VERSION( [NEED] )</dt>
<dd>
<p><code>VERSION</code> returns the version number of the class (package). If the NEED argument is given then it will check that the current version (as defined by the $VERSION variable in the given package) not less than NEED; it will die if this is not the case. This method is normally called as a class method. This method is called automatically by the <code>VERSION</code> form of <code>use</code>.</p>
<pre><code> use A 1.2 qw(some imported subs);
# implies:
A->VERSION(1.2);</code></pre>
</dd>
</dl>
<p><b>NOTE:</b> <code>can</code> directly uses Perl's internal code for method lookup, and <code>isa</code> uses a very similar method and caching strategy. This may cause strange effects if the Perl code dynamically changes @ISA in any package.</p>
<p>You may add other methods to the UNIVERSAL class via Perl or XS code. You do not need to <code>use UNIVERSAL</code> in order to make these methods available to your program. This is necessary only if you wish to have <code>isa</code> available as a plain subroutine in the current package.</p>
<h2 id="TIEHANDLE-now-supported">TIEHANDLE now supported</h2>
<p>See <a href="/cperl/perltie.html">perltie</a> for other kinds of tie()s.</p>
<dl>
<dt id="TIEHANDLE-classname-LIST">TIEHANDLE classname, LIST</dt>
<dd>
<p>This is the constructor for the class. That means it is expected to return an object of some sort. The reference can be used to hold some internal information.</p>
<pre><code> sub TIEHANDLE {
print "<shout>\n";
my $i;
return bless \$i, shift;
}</code></pre>
</dd>
<dt id="PRINT-this-LIST">PRINT this, LIST</dt>
<dd>
<p>This method will be triggered every time the tied handle is printed to. Beyond its self reference it also expects the list that was passed to the print function.</p>
<pre><code> sub PRINT {
$r = shift;
$$r++;
return print join( $, => map {uc} @_), $\;
}</code></pre>
</dd>
<dt id="PRINTF-this-LIST">PRINTF this, LIST</dt>
<dd>
<p>This method will be triggered every time the tied handle is printed to with the <code>printf()</code> function. Beyond its self reference it also expects the format and list that was passed to the printf function.</p>
<pre><code> sub PRINTF {
shift;
my $fmt = shift;
print sprintf($fmt, @_)."\n";
}</code></pre>
</dd>
<dt id="READ-this-LIST">READ this LIST</dt>
<dd>
<p>This method will be called when the handle is read from via the <code>read</code> or <code>sysread</code> functions.</p>
<pre><code> sub READ {
$r = shift;
my($buf,$len,$offset) = @_;
print "READ called, \$buf=$buf, \$len=$len, \$offset=$offset";
}</code></pre>
</dd>
<dt id="READLINE-this">READLINE this</dt>
<dd>
<p>This method will be called when the handle is read from. The method should return undef when there is no more data.</p>
<pre><code> sub READLINE {
$r = shift;
return "PRINT called $$r times\n"
}</code></pre>
</dd>
<dt id="GETC-this">GETC this</dt>
<dd>
<p>This method will be called when the <code>getc</code> function is called.</p>
<pre><code> sub GETC { print "Don't GETC, Get Perl"; return "a"; }</code></pre>
</dd>
<dt id="DESTROY-this">DESTROY this</dt>
<dd>
<p>As with the other types of ties, this method will be called when the tied handle is about to be destroyed. This is useful for debugging and possibly for cleaning up.</p>
<pre><code> sub DESTROY {
print "</shout>\n";
}</code></pre>
</dd>
</dl>
<h2 id="Malloc-enhancements">Malloc enhancements</h2>
<p>If perl is compiled with the malloc included with the perl distribution (that is, if <code>perl -V:d_mymalloc</code> is 'define') then you can print memory statistics at runtime by running Perl thusly:</p>
<pre><code> env PERL_DEBUG_MSTATS=2 perl your_script_here</code></pre>
<p>The value of 2 means to print statistics after compilation and on exit; with a value of 1, the statistics are printed only on exit. (If you want the statistics at an arbitrary time, you'll need to install the optional module Devel::Peek.)</p>
<p>Three new compilation flags are recognized by malloc.c. (They have no effect if perl is compiled with system malloc().)</p>
<dl>
<dt id="DPERL_EMERGENCY_SBRK">-DPERL_EMERGENCY_SBRK</dt>
<dd>
<p>If this macro is defined, running out of memory need not be a fatal error: a memory pool can allocated by assigning to the special variable <code>$^M</code>. See <a href="#M">"$^M"</a>.</p>
</dd>
<dt id="DPACK_MALLOC">-DPACK_MALLOC</dt>
<dd>
<p>Perl memory allocation is by bucket with sizes close to powers of two. Because of these malloc overhead may be big, especially for data of size exactly a power of two. If <code>PACK_MALLOC</code> is defined, perl uses a slightly different algorithm for small allocations (up to 64 bytes long), which makes it possible to have overhead down to 1 byte for allocations which are powers of two (and appear quite often).</p>
<p>Expected memory savings (with 8-byte alignment in <code>alignbytes</code>) is about 20% for typical Perl usage. Expected slowdown due to additional malloc overhead is in fractions of a percent (hard to measure, because of the effect of saved memory on speed).</p>
</dd>
<dt id="DTWO_POT_OPTIMIZE">-DTWO_POT_OPTIMIZE</dt>
<dd>
<p>Similarly to <code>PACK_MALLOC</code>, this macro improves allocations of data with size close to a power of two; but this works for big allocations (starting with 16K by default). Such allocations are typical for big hashes and special-purpose scripts, especially image processing.</p>
<p>On recent systems, the fact that perl requires 2M from system for 1M allocation will not affect speed of execution, since the tail of such a chunk is not going to be touched (and thus will not require real memory). However, it may result in a premature out-of-memory error. So if you will be manipulating very large blocks with sizes close to powers of two, it would be wise to define this macro.</p>
<p>Expected saving of memory is 0-100% (100% in applications which require most memory in such 2**n chunks); expected slowdown is negligible.</p>
</dd>
</dl>
<h2 id="Miscellaneous-efficiency-enhancements">Miscellaneous efficiency enhancements</h2>
<p>Functions that have an empty prototype and that do nothing but return a fixed value are now inlined (e.g. <code>sub PI () { 3.14159 }</code>).</p>
<p>Each unique hash key is only allocated once, no matter how many hashes have an entry with that key. So even if you have 100 copies of the same hash, the hash keys never have to be reallocated.</p>
<h1 id="Support-for-More-Operating-Systems">Support for More Operating Systems</h1>
<p>Support for the following operating systems is new in Perl 5.004.</p>
<h2 id="Win32">Win32</h2>
<p>Perl 5.004 now includes support for building a "native" perl under Windows NT, using the Microsoft Visual C++ compiler (versions 2.0 and above) or the Borland C++ compiler (versions 5.02 and above). The resulting perl can be used under Windows 95 (if it is installed in the same directory locations as it got installed in Windows NT). This port includes support for perl extension building tools like <a href="/cperl/lib/ExtUtils/MakeMaker.html">ExtUtils::MakeMaker</a> and <a>h2xs</a>, so that many extensions available on the Comprehensive Perl Archive Network (CPAN) can now be readily built under Windows NT. See http://www.perl.com/ for more information on CPAN and <i>README.win32</i> in the perl distribution for more details on how to get started with building this port.</p>
<p>There is also support for building perl under the Cygwin32 environment. Cygwin32 is a set of GNU tools that make it possible to compile and run many Unix programs under Windows NT by providing a mostly Unix-like interface for compilation and execution. See <i>README.cygwin32</i> in the perl distribution for more details on this port and how to obtain the Cygwin32 toolkit.</p>
<h2 id="Plan-9">Plan 9</h2>
<p>See <i>README.plan9</i> in the perl distribution.</p>
<h2 id="QNX">QNX</h2>
<p>See <i>README.qnx</i> in the perl distribution.</p>
<h2 id="AmigaOS">AmigaOS</h2>
<p>See <i>README.amigaos</i> in the perl distribution.</p>
<h1 id="Pragmata">Pragmata</h1>
<p>Six new pragmatic modules exist:</p>
<dl>
<dt id="use-autouse-MODULE-qw-sub1-sub2-sub3">use autouse MODULE => qw(sub1 sub2 sub3)</dt>
<dd>
<p>Defers <code>require MODULE</code> until someone calls one of the specified subroutines (which must be exported by MODULE). This pragma should be used with caution, and only when necessary.</p>
</dd>
<dt id="use-blib">use blib</dt>
<dd>
</dd>
<dt id="use-blib-dir">use blib 'dir'</dt>
<dd>
<p>Looks for MakeMaker-like <i>'blib'</i> directory structure starting in <i>dir</i> (or current directory) and working back up to five levels of parent directories.</p>
<p>Intended for use on command line with <b>-M</b> option as a way of testing arbitrary scripts against an uninstalled version of a package.</p>
</dd>
<dt id="use-constant-NAME-VALUE">use constant NAME => VALUE</dt>
<dd>
<p>Provides a convenient interface for creating compile-time constants, See <a href="/cperl/perlsub.html#Constant-Functions">"Constant Functions" in perlsub</a>.</p>
</dd>
<dt id="use-locale">use locale</dt>
<dd>
<p>Tells the compiler to enable (or disable) the use of POSIX locales for builtin operations.</p>
<p>When <code>use locale</code> is in effect, the current LC_CTYPE locale is used for regular expressions and case mapping; LC_COLLATE for string ordering; and LC_NUMERIC for numeric formatting in printf and sprintf (but <b>not</b> in print). LC_NUMERIC is always used in write, since lexical scoping of formats is problematic at best.</p>
<p>Each <code>use locale</code> or <code>no locale</code> affects statements to the end of the enclosing BLOCK or, if not inside a BLOCK, to the end of the current file. Locales can be switched and queried with POSIX::setlocale().</p>
<p>See <a href="/cperl/perllocale.html">perllocale</a> for more information.</p>
</dd>
<dt id="use-ops">use ops</dt>
<dd>
<p>Disable unsafe opcodes, or any named opcodes, when compiling Perl code.</p>
</dd>
<dt id="use-vmsish">use vmsish</dt>
<dd>
<p>Enable VMS-specific language features. Currently, there are three VMS-specific features available: 'status', which makes <code>$?</code> and <code>system</code> return genuine VMS status values instead of emulating POSIX; 'exit', which makes <code>exit</code> take a genuine VMS status value instead of assuming that <code>exit 1</code> is an error; and 'time', which makes all times relative to the local time zone, in the VMS tradition.</p>
</dd>
</dl>
<h1 id="Modules">Modules</h1>
<h2 id="Required-Updates">Required Updates</h2>
<p>Though Perl 5.004 is compatible with almost all modules that work with Perl 5.003, there are a few exceptions:</p>
<pre><code> Module Required Version for Perl 5.004
------ -------------------------------
Filter Filter-1.12
LWP libwww-perl-5.08
Tk Tk400.202 (-w makes noise)</code></pre>
<p>Also, the majordomo mailing list program, version 1.94.1, doesn't work with Perl 5.004 (nor with perl 4), because it executes an invalid regular expression. This bug is fixed in majordomo version 1.94.2.</p>
<h2 id="Installation-directories">Installation directories</h2>
<p>The <i>installperl</i> script now places the Perl source files for extensions in the architecture-specific library directory, which is where the shared libraries for extensions have always been. This change is intended to allow administrators to keep the Perl 5.004 library directory unchanged from a previous version, without running the risk of binary incompatibility between extensions' Perl source and shared libraries.</p>
<h2 id="Module-information-summary">Module information summary</h2>
<p>Brand new modules, arranged by topic rather than strictly alphabetically:</p>
<pre><code> CGI.pm Web server interface ("Common Gateway Interface")
CGI/Apache.pm Support for Apache's Perl module
CGI/Carp.pm Log server errors with helpful context
CGI/Fast.pm Support for FastCGI (persistent server process)
CGI/Push.pm Support for server push
CGI/Switch.pm Simple interface for multiple server types
CPAN Interface to Comprehensive Perl Archive Network
CPAN::FirstTime Utility for creating CPAN configuration file
CPAN::Nox Runs CPAN while avoiding compiled extensions
IO.pm Top-level interface to IO::* classes
IO/File.pm IO::File extension Perl module
IO/Handle.pm IO::Handle extension Perl module
IO/Pipe.pm IO::Pipe extension Perl module
IO/Seekable.pm IO::Seekable extension Perl module
IO/Select.pm IO::Select extension Perl module
IO/Socket.pm IO::Socket extension Perl module
Opcode.pm Disable named opcodes when compiling Perl code
ExtUtils/Embed.pm Utilities for embedding Perl in C programs
ExtUtils/testlib.pm Fixes up @INC to use just-built extension
FindBin.pm Find path of currently executing program
Class/Struct.pm Declare struct-like datatypes as Perl classes
File/stat.pm By-name interface to Perl's builtin stat
Net/hostent.pm By-name interface to Perl's builtin gethost*
Net/netent.pm By-name interface to Perl's builtin getnet*
Net/protoent.pm By-name interface to Perl's builtin getproto*
Net/servent.pm By-name interface to Perl's builtin getserv*
Time/gmtime.pm By-name interface to Perl's builtin gmtime
Time/localtime.pm By-name interface to Perl's builtin localtime
Time/tm.pm Internal object for Time::{gm,local}time
User/grent.pm By-name interface to Perl's builtin getgr*
User/pwent.pm By-name interface to Perl's builtin getpw*
Tie/RefHash.pm Base class for tied hashes with references as keys
UNIVERSAL.pm Base class for *ALL* classes</code></pre>
<h2 id="Fcntl">Fcntl</h2>
<p>New constants in the existing Fcntl modules are now supported, provided that your operating system happens to support them:</p>
<pre><code> F_GETOWN F_SETOWN
O_ASYNC O_DEFER O_DSYNC O_FSYNC O_SYNC
O_EXLOCK O_SHLOCK</code></pre>
<p>These constants are intended for use with the Perl operators sysopen() and fcntl() and the basic database modules like SDBM_File. For the exact meaning of these and other Fcntl constants please refer to your operating system's documentation for fcntl() and open().</p>
<p>In addition, the Fcntl module now provides these constants for use with the Perl operator flock():</p>
<pre><code> LOCK_SH LOCK_EX LOCK_NB LOCK_UN</code></pre>
<p>These constants are defined in all environments (because where there is no flock() system call, Perl emulates it). However, for historical reasons, these constants are not exported unless they are explicitly requested with the ":flock" tag (e.g. <code>use Fcntl ':flock'</code>).</p>
<h2 id="IO">IO</h2>
<p>The IO module provides a simple mechanism to load all the IO modules at one go. Currently this includes:</p>
<pre><code> IO::Handle
IO::Seekable
IO::File
IO::Pipe
IO::Socket</code></pre>
<p>For more information on any of these modules, please see its respective documentation.</p>
<h2 id="Math::Complex">Math::Complex</h2>
<p>The Math::Complex module has been totally rewritten, and now supports more operations. These are overloaded:</p>
<pre><code> + - * / ** <=> neg ~ abs sqrt exp log sin cos atan2 "" (stringify)</code></pre>
<p>And these functions are now exported:</p>
<pre><code> pi i Re Im arg
log10 logn ln cbrt root
tan
csc sec cot
asin acos atan
acsc asec acot
sinh cosh tanh
csch sech coth
asinh acosh atanh
acsch asech acoth
cplx cplxe</code></pre>
<h2 id="Math::Trig">Math::Trig</h2>
<p>This new module provides a simpler interface to parts of Math::Complex for those who need trigonometric functions only for real numbers.</p>
<h2 id="DB_File">DB_File</h2>
<p>There have been quite a few changes made to DB_File. Here are a few of the highlights:</p>
<ul>
<li><p>Fixed a handful of bugs.</p>
</li>
<li><p>By public demand, added support for the standard hash function exists().</p>
</li>
<li><p>Made it compatible with Berkeley DB 1.86.</p>
</li>
<li><p>Made negative subscripts work with RECNO interface.</p>
</li>
<li><p>Changed the default flags from O_RDWR to O_CREAT|O_RDWR and the default mode from 0640 to 0666.</p>
</li>
<li><p>Made DB_File automatically import the open() constants (O_RDWR, O_CREAT etc.) from Fcntl, if available.</p>
</li>
<li><p>Updated documentation.</p>
</li>
</ul>
<p>Refer to the HISTORY section in DB_File.pm for a complete list of changes. Everything after DB_File 1.01 has been added since 5.003.</p>
<h2 id="Net::Ping">Net::Ping</h2>
<p>Major rewrite - support added for both udp echo and real icmp pings.</p>
<h2 id="Object-oriented-overrides-for-builtin-operators">Object-oriented overrides for builtin operators</h2>
<p>Many of the Perl builtins returning lists now have object-oriented overrides. These are:</p>
<pre><code> File::stat
Net::hostent
Net::netent
Net::protoent
Net::servent
Time::gmtime
Time::localtime
User::grent
User::pwent</code></pre>
<p>For example, you can now say</p>
<pre><code> use File::stat;
use User::pwent;
$his = (stat($filename)->st_uid == pwent($whoever)->pw_uid);</code></pre>
<h1 id="Utility-Changes">Utility Changes</h1>
<h2 id="pod2html">pod2html</h2>
<dl>
<dt id="Sends-converted-HTML-to-standard-output">Sends converted HTML to standard output</dt>
<dd>
<p>The <i>pod2html</i> utility included with Perl 5.004 is entirely new. By default, it sends the converted HTML to its standard output, instead of writing it to a file like Perl 5.003's <i>pod2html</i> did. Use the <b>--outfile=FILENAME</b> option to write to a file.</p>
</dd>
</dl>
<h2 id="xsubpp">xsubpp</h2>
<dl>
<dt id="void-XSUBs-now-default-to-returning-nothing"><code>void</code> XSUBs now default to returning nothing</dt>
<dd>
<p>Due to a documentation/implementation bug in previous versions of Perl, XSUBs with a return type of <code>void</code> have actually been returning one value. Usually that value was the GV for the XSUB, but sometimes it was some already freed or reused value, which would sometimes lead to program failure.</p>
<p>In Perl 5.004, if an XSUB is declared as returning <code>void</code>, it actually returns no value, i.e. an empty list (though there is a backward-compatibility exception; see below). If your XSUB really does return an SV, you should give it a return type of <code>SV *</code>.</p>
<p>For backward compatibility, <i>xsubpp</i> tries to guess whether a <code>void</code> XSUB is really <code>void</code> or if it wants to return an <code>SV *</code>. It does so by examining the text of the XSUB: if <i>xsubpp</i> finds what looks like an assignment to <code>ST(0)</code>, it assumes that the XSUB's return type is really <code>SV *</code>.</p>
</dd>
</dl>
<h1 id="C-Language-API-Changes">C Language API Changes</h1>
<dl>
<dt id="gv_fetchmethod-and-perl_call_sv"><code>gv_fetchmethod</code> and <code>perl_call_sv</code></dt>
<dd>
<p>The <code>gv_fetchmethod</code> function finds a method for an object, just like in Perl 5.003. The GV it returns may be a method cache entry. However, in Perl 5.004, method cache entries are not visible to users; therefore, they can no longer be passed directly to <code>perl_call_sv</code>. Instead, you should use the <code>GvCV</code> macro on the GV to extract its CV, and pass the CV to <code>perl_call_sv</code>.</p>
<p>The most likely symptom of passing the result of <code>gv_fetchmethod</code> to <code>perl_call_sv</code> is Perl's producing an "Undefined subroutine called" error on the <i>second</i> call to a given method (since there is no cache on the first call).</p>
</dd>
<dt id="perl_eval_pv"><code>perl_eval_pv</code></dt>
<dd>
<p>A new function handy for eval'ing strings of Perl code inside C code. This function returns the value from the eval statement, which can be used instead of fetching globals from the symbol table. See <a href="/cperl/perlguts.html">perlguts</a>, <a href="/cperl/perlembed.html">perlembed</a> and <a href="/cperl/perlcall.html">perlcall</a> for details and examples.</p>
</dd>
<dt id="Extended-API-for-manipulating-hashes">Extended API for manipulating hashes</dt>
<dd>
<p>Internal handling of hash keys has changed. The old hashtable API is still fully supported, and will likely remain so. The additions to the API allow passing keys as <code>SV*</code>s, so that <code>tied</code> hashes can be given real scalars as keys rather than plain strings (nontied hashes still can only use strings as keys). New extensions must use the new hash access functions and macros if they wish to use <code>SV*</code> keys. These additions also make it feasible to manipulate <code>HE*</code>s (hash entries), which can be more efficient. See <a href="/cperl/perlguts.html">perlguts</a> for details.</p>
</dd>
</dl>
<h1 id="Documentation-Changes">Documentation Changes</h1>
<p>Many of the base and library pods were updated. These new pods are included in section 1:</p>
<dl>
<dt id="perldelta"><a href="/cperl/perldelta.html">perldelta</a></dt>
<dd>
<p>This document.</p>
</dd>
<dt id="perlfaq"><a href="/cperl/lib/perlfaq.html">perlfaq</a></dt>
<dd>
<p>Frequently asked questions.</p>
</dd>
<dt id="perllocale"><a href="/cperl/perllocale.html">perllocale</a></dt>
<dd>
<p>Locale support (internationalization and localization).</p>
</dd>
<dt id="perltoot"><a href="/cperl/perltoot.html">perltoot</a></dt>
<dd>
<p>Tutorial on Perl OO programming.</p>
</dd>
<dt id="perlapio"><a href="/cperl/perlapio.html">perlapio</a></dt>
<dd>
<p>Perl internal IO abstraction interface.</p>
</dd>
<dt id="perlmodlib"><a href="/cperl/perlmodlib.html">perlmodlib</a></dt>
<dd>
<p>Perl module library and recommended practice for module creation. Extracted from <a href="/cperl/perlmod.html">perlmod</a> (which is much smaller as a result).</p>
</dd>
<dt id="perldebug"><a href="/cperl/perldebug.html">perldebug</a></dt>
<dd>
<p>Although not new, this has been massively updated.</p>