1*0Sstevel@tonic-gate=head1 NAME 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateperl5004delta - what's new for perl5.004 4*0Sstevel@tonic-gate 5*0Sstevel@tonic-gate=head1 DESCRIPTION 6*0Sstevel@tonic-gate 7*0Sstevel@tonic-gateThis document describes differences between the 5.003 release (as 8*0Sstevel@tonic-gatedocumented in I<Programming Perl>, second edition--the Camel Book) and 9*0Sstevel@tonic-gatethis one. 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gate=head1 Supported Environments 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gatePerl5.004 builds out of the box on Unix, Plan 9, LynxOS, VMS, OS/2, 14*0Sstevel@tonic-gateQNX, AmigaOS, and Windows NT. Perl runs on Windows 95 as well, but it 15*0Sstevel@tonic-gatecannot be built there, for lack of a reasonable command interpreter. 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gate=head1 Core Changes 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gateMost importantly, many bugs were fixed, including several security 20*0Sstevel@tonic-gateproblems. See the F<Changes> file in the distribution for details. 21*0Sstevel@tonic-gate 22*0Sstevel@tonic-gate=head2 List assignment to %ENV works 23*0Sstevel@tonic-gate 24*0Sstevel@tonic-gateC<%ENV = ()> and C<%ENV = @list> now work as expected (except on VMS 25*0Sstevel@tonic-gatewhere it generates a fatal error). 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate=head2 Change to "Can't locate Foo.pm in @INC" error 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gateThe error "Can't locate Foo.pm in @INC" now lists the contents of @INC 30*0Sstevel@tonic-gatefor easier debugging. 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate=head2 Compilation option: Binary compatibility with 5.003 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gateThere is a new Configure question that asks if you want to maintain 35*0Sstevel@tonic-gatebinary compatibility with Perl 5.003. If you choose binary 36*0Sstevel@tonic-gatecompatibility, you do not have to recompile your extensions, but you 37*0Sstevel@tonic-gatemight have symbol conflicts if you embed Perl in another application, 38*0Sstevel@tonic-gatejust as in the 5.003 release. By default, binary compatibility 39*0Sstevel@tonic-gateis preserved at the expense of symbol table pollution. 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate=head2 $PERL5OPT environment variable 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gateYou may now put Perl options in the $PERL5OPT environment variable. 44*0Sstevel@tonic-gateUnless Perl is running with taint checks, it will interpret this 45*0Sstevel@tonic-gatevariable as if its contents had appeared on a "#!perl" line at the 46*0Sstevel@tonic-gatebeginning of your script, except that hyphens are optional. PERL5OPT 47*0Sstevel@tonic-gatemay only be used to set the following switches: B<-[DIMUdmw]>. 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate=head2 Limitations on B<-M>, B<-m>, and B<-T> options 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gateThe C<-M> and C<-m> options are no longer allowed on the C<#!> line of 52*0Sstevel@tonic-gatea script. If a script needs a module, it should invoke it with the 53*0Sstevel@tonic-gateC<use> pragma. 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gateThe B<-T> option is also forbidden on the C<#!> line of a script, 56*0Sstevel@tonic-gateunless it was present on the Perl command line. Due to the way C<#!> 57*0Sstevel@tonic-gateworks, this usually means that B<-T> must be in the first argument. 58*0Sstevel@tonic-gateThus: 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate #!/usr/bin/perl -T -w 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gatewill probably work for an executable script invoked as C<scriptname>, 63*0Sstevel@tonic-gatewhile: 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate #!/usr/bin/perl -w -T 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gatewill probably fail under the same conditions. (Non-Unix systems will 68*0Sstevel@tonic-gateprobably not follow this rule.) But C<perl scriptname> is guaranteed 69*0Sstevel@tonic-gateto fail, since then there is no chance of B<-T> being found on the 70*0Sstevel@tonic-gatecommand line before it is found on the C<#!> line. 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate=head2 More precise warnings 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gateIf you removed the B<-w> option from your Perl 5.003 scripts because it 75*0Sstevel@tonic-gatemade Perl too verbose, we recommend that you try putting it back when 76*0Sstevel@tonic-gateyou upgrade to Perl 5.004. Each new perl version tends to remove some 77*0Sstevel@tonic-gateundesirable warnings, while adding new warnings that may catch bugs in 78*0Sstevel@tonic-gateyour scripts. 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate=head2 Deprecated: Inherited C<AUTOLOAD> for non-methods 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gateBefore Perl 5.004, C<AUTOLOAD> functions were looked up as methods 83*0Sstevel@tonic-gate(using the C<@ISA> hierarchy), even when the function to be autoloaded 84*0Sstevel@tonic-gatewas called as a plain function (e.g. C<Foo::bar()>), not a method 85*0Sstevel@tonic-gate(e.g. C<< Foo->bar() >> or C<< $obj->bar() >>). 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gatePerl 5.005 will use method lookup only for methods' C<AUTOLOAD>s. 88*0Sstevel@tonic-gateHowever, there is a significant base of existing code that may be using 89*0Sstevel@tonic-gatethe old behavior. So, as an interim step, Perl 5.004 issues an optional 90*0Sstevel@tonic-gatewarning when a non-method uses an inherited C<AUTOLOAD>. 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gateThe simple rule is: Inheritance will not work when autoloading 93*0Sstevel@tonic-gatenon-methods. The simple fix for old code is: In any module that used to 94*0Sstevel@tonic-gatedepend on inheriting C<AUTOLOAD> for non-methods from a base class named 95*0Sstevel@tonic-gateC<BaseClass>, execute C<*AUTOLOAD = \&BaseClass::AUTOLOAD> during startup. 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate=head2 Previously deprecated %OVERLOAD is no longer usable 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gateUsing %OVERLOAD to define overloading was deprecated in 5.003. 100*0Sstevel@tonic-gateOverloading is now defined using the overload pragma. %OVERLOAD is 101*0Sstevel@tonic-gatestill used internally but should not be used by Perl scripts. See 102*0Sstevel@tonic-gateL<overload> for more details. 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate=head2 Subroutine arguments created only when they're modified 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gateIn Perl 5.004, nonexistent array and hash elements used as subroutine 107*0Sstevel@tonic-gateparameters are brought into existence only if they are actually 108*0Sstevel@tonic-gateassigned to (via C<@_>). 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gateEarlier versions of Perl vary in their handling of such arguments. 111*0Sstevel@tonic-gatePerl versions 5.002 and 5.003 always brought them into existence. 112*0Sstevel@tonic-gatePerl versions 5.000 and 5.001 brought them into existence only if 113*0Sstevel@tonic-gatethey were not the first argument (which was almost certainly a bug). 114*0Sstevel@tonic-gateEarlier versions of Perl never brought them into existence. 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gateFor example, given this code: 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate undef @a; undef %a; 119*0Sstevel@tonic-gate sub show { print $_[0] }; 120*0Sstevel@tonic-gate sub change { $_[0]++ }; 121*0Sstevel@tonic-gate show($a[2]); 122*0Sstevel@tonic-gate change($a{b}); 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gateAfter this code executes in Perl 5.004, $a{b} exists but $a[2] does 125*0Sstevel@tonic-gatenot. In Perl 5.002 and 5.003, both $a{b} and $a[2] would have existed 126*0Sstevel@tonic-gate(but $a[2]'s value would have been undefined). 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate=head2 Group vector changeable with C<$)> 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gateThe C<$)> special variable has always (well, in Perl 5, at least) 131*0Sstevel@tonic-gatereflected not only the current effective group, but also the group list 132*0Sstevel@tonic-gateas returned by the C<getgroups()> C function (if there is one). 133*0Sstevel@tonic-gateHowever, until this release, there has not been a way to call the 134*0Sstevel@tonic-gateC<setgroups()> C function from Perl. 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gateIn Perl 5.004, assigning to C<$)> is exactly symmetrical with examining 137*0Sstevel@tonic-gateit: The first number in its string value is used as the effective gid; 138*0Sstevel@tonic-gateif there are any numbers after the first one, they are passed to the 139*0Sstevel@tonic-gateC<setgroups()> C function (if there is one). 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate=head2 Fixed parsing of $$<digit>, &$<digit>, etc. 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gatePerl versions before 5.004 misinterpreted any type marker followed by 144*0Sstevel@tonic-gate"$" and a digit. For example, "$$0" was incorrectly taken to mean 145*0Sstevel@tonic-gate"${$}0" instead of "${$0}". This bug is (mostly) fixed in Perl 5.004. 146*0Sstevel@tonic-gate 147*0Sstevel@tonic-gateHowever, the developers of Perl 5.004 could not fix this bug completely, 148*0Sstevel@tonic-gatebecause at least two widely-used modules depend on the old meaning of 149*0Sstevel@tonic-gate"$$0" in a string. So Perl 5.004 still interprets "$$<digit>" in the 150*0Sstevel@tonic-gateold (broken) way inside strings; but it generates this message as a 151*0Sstevel@tonic-gatewarning. And in Perl 5.005, this special treatment will cease. 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gate=head2 Fixed localization of $<digit>, $&, etc. 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gatePerl versions before 5.004 did not always properly localize the 156*0Sstevel@tonic-gateregex-related special variables. Perl 5.004 does localize them, as 157*0Sstevel@tonic-gatethe documentation has always said it should. This may result in $1, 158*0Sstevel@tonic-gate$2, etc. no longer being set where existing programs use them. 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate=head2 No resetting of $. on implicit close 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gateThe documentation for Perl 5.0 has always stated that C<$.> is I<not> 163*0Sstevel@tonic-gatereset when an already-open file handle is reopened with no intervening 164*0Sstevel@tonic-gatecall to C<close>. Due to a bug, perl versions 5.000 through 5.003 165*0Sstevel@tonic-gateI<did> reset C<$.> under that circumstance; Perl 5.004 does not. 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate=head2 C<wantarray> may return undef 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gateThe C<wantarray> operator returns true if a subroutine is expected to 170*0Sstevel@tonic-gatereturn a list, and false otherwise. In Perl 5.004, C<wantarray> can 171*0Sstevel@tonic-gatealso return the undefined value if a subroutine's return value will 172*0Sstevel@tonic-gatenot be used at all, which allows subroutines to avoid a time-consuming 173*0Sstevel@tonic-gatecalculation of a return value if it isn't going to be used. 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate=head2 C<eval EXPR> determines value of EXPR in scalar context 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gatePerl (version 5) used to determine the value of EXPR inconsistently, 178*0Sstevel@tonic-gatesometimes incorrectly using the surrounding context for the determination. 179*0Sstevel@tonic-gateNow, the value of EXPR (before being parsed by eval) is always determined in 180*0Sstevel@tonic-gatea scalar context. Once parsed, it is executed as before, by providing 181*0Sstevel@tonic-gatethe context that the scope surrounding the eval provided. This change 182*0Sstevel@tonic-gatemakes the behavior Perl4 compatible, besides fixing bugs resulting from 183*0Sstevel@tonic-gatethe inconsistent behavior. This program: 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate @a = qw(time now is time); 186*0Sstevel@tonic-gate print eval @a; 187*0Sstevel@tonic-gate print '|', scalar eval @a; 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gateused to print something like "timenowis881399109|4", but now (and in perl4) 190*0Sstevel@tonic-gateprints "4|4". 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate=head2 Changes to tainting checks 193*0Sstevel@tonic-gate 194*0Sstevel@tonic-gateA bug in previous versions may have failed to detect some insecure 195*0Sstevel@tonic-gateconditions when taint checks are turned on. (Taint checks are used 196*0Sstevel@tonic-gatein setuid or setgid scripts, or when explicitly turned on with the 197*0Sstevel@tonic-gateC<-T> invocation option.) Although it's unlikely, this may cause a 198*0Sstevel@tonic-gatepreviously-working script to now fail -- which should be construed 199*0Sstevel@tonic-gateas a blessing, since that indicates a potentially-serious security 200*0Sstevel@tonic-gatehole was just plugged. 201*0Sstevel@tonic-gate 202*0Sstevel@tonic-gateThe new restrictions when tainting include: 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate=over 4 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate=item No glob() or <*> 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gateThese operators may spawn the C shell (csh), which cannot be made 209*0Sstevel@tonic-gatesafe. This restriction will be lifted in a future version of Perl 210*0Sstevel@tonic-gatewhen globbing is implemented without the use of an external program. 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate=item No spawning if tainted $CDPATH, $ENV, $BASH_ENV 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gateThese environment variables may alter the behavior of spawned programs 215*0Sstevel@tonic-gate(especially shells) in ways that subvert security. So now they are 216*0Sstevel@tonic-gatetreated as dangerous, in the manner of $IFS and $PATH. 217*0Sstevel@tonic-gate 218*0Sstevel@tonic-gate=item No spawning if tainted $TERM doesn't look like a terminal name 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gateSome termcap libraries do unsafe things with $TERM. However, it would be 221*0Sstevel@tonic-gateunnecessarily harsh to treat all $TERM values as unsafe, since only shell 222*0Sstevel@tonic-gatemetacharacters can cause trouble in $TERM. So a tainted $TERM is 223*0Sstevel@tonic-gateconsidered to be safe if it contains only alphanumerics, underscores, 224*0Sstevel@tonic-gatedashes, and colons, and unsafe if it contains other characters (including 225*0Sstevel@tonic-gatewhitespace). 226*0Sstevel@tonic-gate 227*0Sstevel@tonic-gate=back 228*0Sstevel@tonic-gate 229*0Sstevel@tonic-gate=head2 New Opcode module and revised Safe module 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gateA new Opcode module supports the creation, manipulation and 232*0Sstevel@tonic-gateapplication of opcode masks. The revised Safe module has a new API 233*0Sstevel@tonic-gateand is implemented using the new Opcode module. Please read the new 234*0Sstevel@tonic-gateOpcode and Safe documentation. 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate=head2 Embedding improvements 237*0Sstevel@tonic-gate 238*0Sstevel@tonic-gateIn older versions of Perl it was not possible to create more than one 239*0Sstevel@tonic-gatePerl interpreter instance inside a single process without leaking like a 240*0Sstevel@tonic-gatesieve and/or crashing. The bugs that caused this behavior have all been 241*0Sstevel@tonic-gatefixed. However, you still must take care when embedding Perl in a C 242*0Sstevel@tonic-gateprogram. See the updated perlembed manpage for tips on how to manage 243*0Sstevel@tonic-gateyour interpreters. 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate=head2 Internal change: FileHandle class based on IO::* classes 246*0Sstevel@tonic-gate 247*0Sstevel@tonic-gateFile handles are now stored internally as type IO::Handle. The 248*0Sstevel@tonic-gateFileHandle module is still supported for backwards compatibility, but 249*0Sstevel@tonic-gateit is now merely a front end to the IO::* modules -- specifically, 250*0Sstevel@tonic-gateIO::Handle, IO::Seekable, and IO::File. We suggest, but do not 251*0Sstevel@tonic-gaterequire, that you use the IO::* modules in new code. 252*0Sstevel@tonic-gate 253*0Sstevel@tonic-gateIn harmony with this change, C<*GLOB{FILEHANDLE}> is now just a 254*0Sstevel@tonic-gatebackward-compatible synonym for C<*GLOB{IO}>. 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate=head2 Internal change: PerlIO abstraction interface 257*0Sstevel@tonic-gate 258*0Sstevel@tonic-gateIt is now possible to build Perl with AT&T's sfio IO package 259*0Sstevel@tonic-gateinstead of stdio. See L<perlapio> for more details, and 260*0Sstevel@tonic-gatethe F<INSTALL> file for how to use it. 261*0Sstevel@tonic-gate 262*0Sstevel@tonic-gate=head2 New and changed syntax 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate=over 4 265*0Sstevel@tonic-gate 266*0Sstevel@tonic-gate=item $coderef->(PARAMS) 267*0Sstevel@tonic-gate 268*0Sstevel@tonic-gateA subroutine reference may now be suffixed with an arrow and a 269*0Sstevel@tonic-gate(possibly empty) parameter list. This syntax denotes a call of the 270*0Sstevel@tonic-gatereferenced subroutine, with the given parameters (if any). 271*0Sstevel@tonic-gate 272*0Sstevel@tonic-gateThis new syntax follows the pattern of S<C<< $hashref->{FOO} >>> and 273*0Sstevel@tonic-gateS<C<< $aryref->[$foo] >>>: You may now write S<C<&$subref($foo)>> as 274*0Sstevel@tonic-gateS<C<< $subref->($foo) >>>. All these arrow terms may be chained; 275*0Sstevel@tonic-gatethus, S<C<< &{$table->{FOO}}($bar) >>> may now be written 276*0Sstevel@tonic-gateS<C<< $table->{FOO}->($bar) >>>. 277*0Sstevel@tonic-gate 278*0Sstevel@tonic-gate=back 279*0Sstevel@tonic-gate 280*0Sstevel@tonic-gate=head2 New and changed builtin constants 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gate=over 4 283*0Sstevel@tonic-gate 284*0Sstevel@tonic-gate=item __PACKAGE__ 285*0Sstevel@tonic-gate 286*0Sstevel@tonic-gateThe current package name at compile time, or the undefined value if 287*0Sstevel@tonic-gatethere is no current package (due to a C<package;> directive). Like 288*0Sstevel@tonic-gateC<__FILE__> and C<__LINE__>, C<__PACKAGE__> does I<not> interpolate 289*0Sstevel@tonic-gateinto strings. 290*0Sstevel@tonic-gate 291*0Sstevel@tonic-gate=back 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate=head2 New and changed builtin variables 294*0Sstevel@tonic-gate 295*0Sstevel@tonic-gate=over 4 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate=item $^E 298*0Sstevel@tonic-gate 299*0Sstevel@tonic-gateExtended error message on some platforms. (Also known as 300*0Sstevel@tonic-gate$EXTENDED_OS_ERROR if you C<use English>). 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate=item $^H 303*0Sstevel@tonic-gate 304*0Sstevel@tonic-gateThe current set of syntax checks enabled by C<use strict>. See the 305*0Sstevel@tonic-gatedocumentation of C<strict> for more details. Not actually new, but 306*0Sstevel@tonic-gatenewly documented. 307*0Sstevel@tonic-gateBecause it is intended for internal use by Perl core components, 308*0Sstevel@tonic-gatethere is no C<use English> long name for this variable. 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate=item $^M 311*0Sstevel@tonic-gate 312*0Sstevel@tonic-gateBy default, running out of memory it is not trappable. However, if 313*0Sstevel@tonic-gatecompiled for this, Perl may use the contents of C<$^M> as an emergency 314*0Sstevel@tonic-gatepool after die()ing with this message. Suppose that your Perl were 315*0Sstevel@tonic-gatecompiled with -DPERL_EMERGENCY_SBRK and used Perl's malloc. Then 316*0Sstevel@tonic-gate 317*0Sstevel@tonic-gate $^M = 'a' x (1<<16); 318*0Sstevel@tonic-gate 319*0Sstevel@tonic-gatewould allocate a 64K buffer for use when in emergency. 320*0Sstevel@tonic-gateSee the F<INSTALL> file for information on how to enable this option. 321*0Sstevel@tonic-gateAs a disincentive to casual use of this advanced feature, 322*0Sstevel@tonic-gatethere is no C<use English> long name for this variable. 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate=back 325*0Sstevel@tonic-gate 326*0Sstevel@tonic-gate=head2 New and changed builtin functions 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate=over 4 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate=item delete on slices 331*0Sstevel@tonic-gate 332*0Sstevel@tonic-gateThis now works. (e.g. C<delete @ENV{'PATH', 'MANPATH'}>) 333*0Sstevel@tonic-gate 334*0Sstevel@tonic-gate=item flock 335*0Sstevel@tonic-gate 336*0Sstevel@tonic-gateis now supported on more platforms, prefers fcntl to lockf when 337*0Sstevel@tonic-gateemulating, and always flushes before (un)locking. 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate=item printf and sprintf 340*0Sstevel@tonic-gate 341*0Sstevel@tonic-gatePerl now implements these functions itself; it doesn't use the C 342*0Sstevel@tonic-gatelibrary function sprintf() any more, except for floating-point 343*0Sstevel@tonic-gatenumbers, and even then only known flags are allowed. As a result, it 344*0Sstevel@tonic-gateis now possible to know which conversions and flags will work, and 345*0Sstevel@tonic-gatewhat they will do. 346*0Sstevel@tonic-gate 347*0Sstevel@tonic-gateThe new conversions in Perl's sprintf() are: 348*0Sstevel@tonic-gate 349*0Sstevel@tonic-gate %i a synonym for %d 350*0Sstevel@tonic-gate %p a pointer (the address of the Perl value, in hexadecimal) 351*0Sstevel@tonic-gate %n special: *stores* the number of characters output so far 352*0Sstevel@tonic-gate into the next variable in the parameter list 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gateThe new flags that go between the C<%> and the conversion are: 355*0Sstevel@tonic-gate 356*0Sstevel@tonic-gate # prefix octal with "0", hex with "0x" 357*0Sstevel@tonic-gate h interpret integer as C type "short" or "unsigned short" 358*0Sstevel@tonic-gate V interpret integer as Perl's standard integer type 359*0Sstevel@tonic-gate 360*0Sstevel@tonic-gateAlso, where a number would appear in the flags, an asterisk ("*") may 361*0Sstevel@tonic-gatebe used instead, in which case Perl uses the next item in the 362*0Sstevel@tonic-gateparameter list as the given number (that is, as the field width or 363*0Sstevel@tonic-gateprecision). If a field width obtained through "*" is negative, it has 364*0Sstevel@tonic-gatethe same effect as the '-' flag: left-justification. 365*0Sstevel@tonic-gate 366*0Sstevel@tonic-gateSee L<perlfunc/sprintf> for a complete list of conversion and flags. 367*0Sstevel@tonic-gate 368*0Sstevel@tonic-gate=item keys as an lvalue 369*0Sstevel@tonic-gate 370*0Sstevel@tonic-gateAs an lvalue, C<keys> allows you to increase the number of hash buckets 371*0Sstevel@tonic-gateallocated for the given hash. This can gain you a measure of efficiency if 372*0Sstevel@tonic-gateyou know the hash is going to get big. (This is similar to pre-extending 373*0Sstevel@tonic-gatean array by assigning a larger number to $#array.) If you say 374*0Sstevel@tonic-gate 375*0Sstevel@tonic-gate keys %hash = 200; 376*0Sstevel@tonic-gate 377*0Sstevel@tonic-gatethen C<%hash> will have at least 200 buckets allocated for it. These 378*0Sstevel@tonic-gatebuckets will be retained even if you do C<%hash = ()>; use C<undef 379*0Sstevel@tonic-gate%hash> if you want to free the storage while C<%hash> is still in scope. 380*0Sstevel@tonic-gateYou can't shrink the number of buckets allocated for the hash using 381*0Sstevel@tonic-gateC<keys> in this way (but you needn't worry about doing this by accident, 382*0Sstevel@tonic-gateas trying has no effect). 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate=item my() in Control Structures 385*0Sstevel@tonic-gate 386*0Sstevel@tonic-gateYou can now use my() (with or without the parentheses) in the control 387*0Sstevel@tonic-gateexpressions of control structures such as: 388*0Sstevel@tonic-gate 389*0Sstevel@tonic-gate while (defined(my $line = <>)) { 390*0Sstevel@tonic-gate $line = lc $line; 391*0Sstevel@tonic-gate } continue { 392*0Sstevel@tonic-gate print $line; 393*0Sstevel@tonic-gate } 394*0Sstevel@tonic-gate 395*0Sstevel@tonic-gate if ((my $answer = <STDIN>) =~ /^y(es)?$/i) { 396*0Sstevel@tonic-gate user_agrees(); 397*0Sstevel@tonic-gate } elsif ($answer =~ /^n(o)?$/i) { 398*0Sstevel@tonic-gate user_disagrees(); 399*0Sstevel@tonic-gate } else { 400*0Sstevel@tonic-gate chomp $answer; 401*0Sstevel@tonic-gate die "`$answer' is neither `yes' nor `no'"; 402*0Sstevel@tonic-gate } 403*0Sstevel@tonic-gate 404*0Sstevel@tonic-gateAlso, you can declare a foreach loop control variable as lexical by 405*0Sstevel@tonic-gatepreceding it with the word "my". For example, in: 406*0Sstevel@tonic-gate 407*0Sstevel@tonic-gate foreach my $i (1, 2, 3) { 408*0Sstevel@tonic-gate some_function(); 409*0Sstevel@tonic-gate } 410*0Sstevel@tonic-gate 411*0Sstevel@tonic-gate$i is a lexical variable, and the scope of $i extends to the end of 412*0Sstevel@tonic-gatethe loop, but not beyond it. 413*0Sstevel@tonic-gate 414*0Sstevel@tonic-gateNote that you still cannot use my() on global punctuation variables 415*0Sstevel@tonic-gatesuch as $_ and the like. 416*0Sstevel@tonic-gate 417*0Sstevel@tonic-gate=item pack() and unpack() 418*0Sstevel@tonic-gate 419*0Sstevel@tonic-gateA new format 'w' represents a BER compressed integer (as defined in 420*0Sstevel@tonic-gateASN.1). Its format is a sequence of one or more bytes, each of which 421*0Sstevel@tonic-gateprovides seven bits of the total value, with the most significant 422*0Sstevel@tonic-gatefirst. Bit eight of each byte is set, except for the last byte, in 423*0Sstevel@tonic-gatewhich bit eight is clear. 424*0Sstevel@tonic-gate 425*0Sstevel@tonic-gateIf 'p' or 'P' are given undef as values, they now generate a NULL 426*0Sstevel@tonic-gatepointer. 427*0Sstevel@tonic-gate 428*0Sstevel@tonic-gateBoth pack() and unpack() now fail when their templates contain invalid 429*0Sstevel@tonic-gatetypes. (Invalid types used to be ignored.) 430*0Sstevel@tonic-gate 431*0Sstevel@tonic-gate=item sysseek() 432*0Sstevel@tonic-gate 433*0Sstevel@tonic-gateThe new sysseek() operator is a variant of seek() that sets and gets the 434*0Sstevel@tonic-gatefile's system read/write position, using the lseek(2) system call. It is 435*0Sstevel@tonic-gatethe only reliable way to seek before using sysread() or syswrite(). Its 436*0Sstevel@tonic-gatereturn value is the new position, or the undefined value on failure. 437*0Sstevel@tonic-gate 438*0Sstevel@tonic-gate=item use VERSION 439*0Sstevel@tonic-gate 440*0Sstevel@tonic-gateIf the first argument to C<use> is a number, it is treated as a version 441*0Sstevel@tonic-gatenumber instead of a module name. If the version of the Perl interpreter 442*0Sstevel@tonic-gateis less than VERSION, then an error message is printed and Perl exits 443*0Sstevel@tonic-gateimmediately. Because C<use> occurs at compile time, this check happens 444*0Sstevel@tonic-gateimmediately during the compilation process, unlike C<require VERSION>, 445*0Sstevel@tonic-gatewhich waits until runtime for the check. This is often useful if you 446*0Sstevel@tonic-gateneed to check the current Perl version before C<use>ing library modules 447*0Sstevel@tonic-gatewhich have changed in incompatible ways from older versions of Perl. 448*0Sstevel@tonic-gate(We try not to do this more than we have to.) 449*0Sstevel@tonic-gate 450*0Sstevel@tonic-gate=item use Module VERSION LIST 451*0Sstevel@tonic-gate 452*0Sstevel@tonic-gateIf the VERSION argument is present between Module and LIST, then the 453*0Sstevel@tonic-gateC<use> will call the VERSION method in class Module with the given 454*0Sstevel@tonic-gateversion as an argument. The default VERSION method, inherited from 455*0Sstevel@tonic-gatethe UNIVERSAL class, croaks if the given version is larger than the 456*0Sstevel@tonic-gatevalue of the variable $Module::VERSION. (Note that there is not a 457*0Sstevel@tonic-gatecomma after VERSION!) 458*0Sstevel@tonic-gate 459*0Sstevel@tonic-gateThis version-checking mechanism is similar to the one currently used 460*0Sstevel@tonic-gatein the Exporter module, but it is faster and can be used with modules 461*0Sstevel@tonic-gatethat don't use the Exporter. It is the recommended method for new 462*0Sstevel@tonic-gatecode. 463*0Sstevel@tonic-gate 464*0Sstevel@tonic-gate=item prototype(FUNCTION) 465*0Sstevel@tonic-gate 466*0Sstevel@tonic-gateReturns the prototype of a function as a string (or C<undef> if the 467*0Sstevel@tonic-gatefunction has no prototype). FUNCTION is a reference to or the name of the 468*0Sstevel@tonic-gatefunction whose prototype you want to retrieve. 469*0Sstevel@tonic-gate(Not actually new; just never documented before.) 470*0Sstevel@tonic-gate 471*0Sstevel@tonic-gate=item srand 472*0Sstevel@tonic-gate 473*0Sstevel@tonic-gateThe default seed for C<srand>, which used to be C<time>, has been changed. 474*0Sstevel@tonic-gateNow it's a heady mix of difficult-to-predict system-dependent values, 475*0Sstevel@tonic-gatewhich should be sufficient for most everyday purposes. 476*0Sstevel@tonic-gate 477*0Sstevel@tonic-gatePrevious to version 5.004, calling C<rand> without first calling C<srand> 478*0Sstevel@tonic-gatewould yield the same sequence of random numbers on most or all machines. 479*0Sstevel@tonic-gateNow, when perl sees that you're calling C<rand> and haven't yet called 480*0Sstevel@tonic-gateC<srand>, it calls C<srand> with the default seed. You should still call 481*0Sstevel@tonic-gateC<srand> manually if your code might ever be run on a pre-5.004 system, 482*0Sstevel@tonic-gateof course, or if you want a seed other than the default. 483*0Sstevel@tonic-gate 484*0Sstevel@tonic-gate=item $_ as Default 485*0Sstevel@tonic-gate 486*0Sstevel@tonic-gateFunctions documented in the Camel to default to $_ now in 487*0Sstevel@tonic-gatefact do, and all those that do are so documented in L<perlfunc>. 488*0Sstevel@tonic-gate 489*0Sstevel@tonic-gate=item C<m//gc> does not reset search position on failure 490*0Sstevel@tonic-gate 491*0Sstevel@tonic-gateThe C<m//g> match iteration construct has always reset its target 492*0Sstevel@tonic-gatestring's search position (which is visible through the C<pos> operator) 493*0Sstevel@tonic-gatewhen a match fails; as a result, the next C<m//g> match after a failure 494*0Sstevel@tonic-gatestarts again at the beginning of the string. With Perl 5.004, this 495*0Sstevel@tonic-gatereset may be disabled by adding the "c" (for "continue") modifier, 496*0Sstevel@tonic-gatei.e. C<m//gc>. This feature, in conjunction with the C<\G> zero-width 497*0Sstevel@tonic-gateassertion, makes it possible to chain matches together. See L<perlop> 498*0Sstevel@tonic-gateand L<perlre>. 499*0Sstevel@tonic-gate 500*0Sstevel@tonic-gate=item C<m//x> ignores whitespace before ?*+{} 501*0Sstevel@tonic-gate 502*0Sstevel@tonic-gateThe C<m//x> construct has always been intended to ignore all unescaped 503*0Sstevel@tonic-gatewhitespace. However, before Perl 5.004, whitespace had the effect of 504*0Sstevel@tonic-gateescaping repeat modifiers like "*" or "?"; for example, C</a *b/x> was 505*0Sstevel@tonic-gate(mis)interpreted as C</a\*b/x>. This bug has been fixed in 5.004. 506*0Sstevel@tonic-gate 507*0Sstevel@tonic-gate=item nested C<sub{}> closures work now 508*0Sstevel@tonic-gate 509*0Sstevel@tonic-gatePrior to the 5.004 release, nested anonymous functions didn't work 510*0Sstevel@tonic-gateright. They do now. 511*0Sstevel@tonic-gate 512*0Sstevel@tonic-gate=item formats work right on changing lexicals 513*0Sstevel@tonic-gate 514*0Sstevel@tonic-gateJust like anonymous functions that contain lexical variables 515*0Sstevel@tonic-gatethat change (like a lexical index variable for a C<foreach> loop), 516*0Sstevel@tonic-gateformats now work properly. For example, this silently failed 517*0Sstevel@tonic-gatebefore (printed only zeros), but is fine now: 518*0Sstevel@tonic-gate 519*0Sstevel@tonic-gate my $i; 520*0Sstevel@tonic-gate foreach $i ( 1 .. 10 ) { 521*0Sstevel@tonic-gate write; 522*0Sstevel@tonic-gate } 523*0Sstevel@tonic-gate format = 524*0Sstevel@tonic-gate my i is @# 525*0Sstevel@tonic-gate $i 526*0Sstevel@tonic-gate . 527*0Sstevel@tonic-gate 528*0Sstevel@tonic-gateHowever, it still fails (without a warning) if the foreach is within a 529*0Sstevel@tonic-gatesubroutine: 530*0Sstevel@tonic-gate 531*0Sstevel@tonic-gate my $i; 532*0Sstevel@tonic-gate sub foo { 533*0Sstevel@tonic-gate foreach $i ( 1 .. 10 ) { 534*0Sstevel@tonic-gate write; 535*0Sstevel@tonic-gate } 536*0Sstevel@tonic-gate } 537*0Sstevel@tonic-gate foo; 538*0Sstevel@tonic-gate format = 539*0Sstevel@tonic-gate my i is @# 540*0Sstevel@tonic-gate $i 541*0Sstevel@tonic-gate . 542*0Sstevel@tonic-gate 543*0Sstevel@tonic-gate=back 544*0Sstevel@tonic-gate 545*0Sstevel@tonic-gate=head2 New builtin methods 546*0Sstevel@tonic-gate 547*0Sstevel@tonic-gateThe C<UNIVERSAL> package automatically contains the following methods that 548*0Sstevel@tonic-gateare inherited by all other classes: 549*0Sstevel@tonic-gate 550*0Sstevel@tonic-gate=over 4 551*0Sstevel@tonic-gate 552*0Sstevel@tonic-gate=item isa(CLASS) 553*0Sstevel@tonic-gate 554*0Sstevel@tonic-gateC<isa> returns I<true> if its object is blessed into a subclass of C<CLASS> 555*0Sstevel@tonic-gate 556*0Sstevel@tonic-gateC<isa> is also exportable and can be called as a sub with two arguments. This 557*0Sstevel@tonic-gateallows the ability to check what a reference points to. Example: 558*0Sstevel@tonic-gate 559*0Sstevel@tonic-gate use UNIVERSAL qw(isa); 560*0Sstevel@tonic-gate 561*0Sstevel@tonic-gate if(isa($ref, 'ARRAY')) { 562*0Sstevel@tonic-gate ... 563*0Sstevel@tonic-gate } 564*0Sstevel@tonic-gate 565*0Sstevel@tonic-gate=item can(METHOD) 566*0Sstevel@tonic-gate 567*0Sstevel@tonic-gateC<can> checks to see if its object has a method called C<METHOD>, 568*0Sstevel@tonic-gateif it does then a reference to the sub is returned; if it does not then 569*0Sstevel@tonic-gateI<undef> is returned. 570*0Sstevel@tonic-gate 571*0Sstevel@tonic-gate=item VERSION( [NEED] ) 572*0Sstevel@tonic-gate 573*0Sstevel@tonic-gateC<VERSION> returns the version number of the class (package). If the 574*0Sstevel@tonic-gateNEED argument is given then it will check that the current version (as 575*0Sstevel@tonic-gatedefined by the $VERSION variable in the given package) not less than 576*0Sstevel@tonic-gateNEED; it will die if this is not the case. This method is normally 577*0Sstevel@tonic-gatecalled as a class method. This method is called automatically by the 578*0Sstevel@tonic-gateC<VERSION> form of C<use>. 579*0Sstevel@tonic-gate 580*0Sstevel@tonic-gate use A 1.2 qw(some imported subs); 581*0Sstevel@tonic-gate # implies: 582*0Sstevel@tonic-gate A->VERSION(1.2); 583*0Sstevel@tonic-gate 584*0Sstevel@tonic-gate=back 585*0Sstevel@tonic-gate 586*0Sstevel@tonic-gateB<NOTE:> C<can> directly uses Perl's internal code for method lookup, and 587*0Sstevel@tonic-gateC<isa> uses a very similar method and caching strategy. This may cause 588*0Sstevel@tonic-gatestrange effects if the Perl code dynamically changes @ISA in any package. 589*0Sstevel@tonic-gate 590*0Sstevel@tonic-gateYou may add other methods to the UNIVERSAL class via Perl or XS code. 591*0Sstevel@tonic-gateYou do not need to C<use UNIVERSAL> in order to make these methods 592*0Sstevel@tonic-gateavailable to your program. This is necessary only if you wish to 593*0Sstevel@tonic-gatehave C<isa> available as a plain subroutine in the current package. 594*0Sstevel@tonic-gate 595*0Sstevel@tonic-gate=head2 TIEHANDLE now supported 596*0Sstevel@tonic-gate 597*0Sstevel@tonic-gateSee L<perltie> for other kinds of tie()s. 598*0Sstevel@tonic-gate 599*0Sstevel@tonic-gate=over 4 600*0Sstevel@tonic-gate 601*0Sstevel@tonic-gate=item TIEHANDLE classname, LIST 602*0Sstevel@tonic-gate 603*0Sstevel@tonic-gateThis is the constructor for the class. That means it is expected to 604*0Sstevel@tonic-gatereturn an object of some sort. The reference can be used to 605*0Sstevel@tonic-gatehold some internal information. 606*0Sstevel@tonic-gate 607*0Sstevel@tonic-gate sub TIEHANDLE { 608*0Sstevel@tonic-gate print "<shout>\n"; 609*0Sstevel@tonic-gate my $i; 610*0Sstevel@tonic-gate return bless \$i, shift; 611*0Sstevel@tonic-gate } 612*0Sstevel@tonic-gate 613*0Sstevel@tonic-gate=item PRINT this, LIST 614*0Sstevel@tonic-gate 615*0Sstevel@tonic-gateThis method will be triggered every time the tied handle is printed to. 616*0Sstevel@tonic-gateBeyond its self reference it also expects the list that was passed to 617*0Sstevel@tonic-gatethe print function. 618*0Sstevel@tonic-gate 619*0Sstevel@tonic-gate sub PRINT { 620*0Sstevel@tonic-gate $r = shift; 621*0Sstevel@tonic-gate $$r++; 622*0Sstevel@tonic-gate return print join( $, => map {uc} @_), $\; 623*0Sstevel@tonic-gate } 624*0Sstevel@tonic-gate 625*0Sstevel@tonic-gate=item PRINTF this, LIST 626*0Sstevel@tonic-gate 627*0Sstevel@tonic-gateThis method will be triggered every time the tied handle is printed to 628*0Sstevel@tonic-gatewith the C<printf()> function. 629*0Sstevel@tonic-gateBeyond its self reference it also expects the format and list that was 630*0Sstevel@tonic-gatepassed to the printf function. 631*0Sstevel@tonic-gate 632*0Sstevel@tonic-gate sub PRINTF { 633*0Sstevel@tonic-gate shift; 634*0Sstevel@tonic-gate my $fmt = shift; 635*0Sstevel@tonic-gate print sprintf($fmt, @_)."\n"; 636*0Sstevel@tonic-gate } 637*0Sstevel@tonic-gate 638*0Sstevel@tonic-gate=item READ this LIST 639*0Sstevel@tonic-gate 640*0Sstevel@tonic-gateThis method will be called when the handle is read from via the C<read> 641*0Sstevel@tonic-gateor C<sysread> functions. 642*0Sstevel@tonic-gate 643*0Sstevel@tonic-gate sub READ { 644*0Sstevel@tonic-gate $r = shift; 645*0Sstevel@tonic-gate my($buf,$len,$offset) = @_; 646*0Sstevel@tonic-gate print "READ called, \$buf=$buf, \$len=$len, \$offset=$offset"; 647*0Sstevel@tonic-gate } 648*0Sstevel@tonic-gate 649*0Sstevel@tonic-gate=item READLINE this 650*0Sstevel@tonic-gate 651*0Sstevel@tonic-gateThis method will be called when the handle is read from. The method 652*0Sstevel@tonic-gateshould return undef when there is no more data. 653*0Sstevel@tonic-gate 654*0Sstevel@tonic-gate sub READLINE { 655*0Sstevel@tonic-gate $r = shift; 656*0Sstevel@tonic-gate return "PRINT called $$r times\n" 657*0Sstevel@tonic-gate } 658*0Sstevel@tonic-gate 659*0Sstevel@tonic-gate=item GETC this 660*0Sstevel@tonic-gate 661*0Sstevel@tonic-gateThis method will be called when the C<getc> function is called. 662*0Sstevel@tonic-gate 663*0Sstevel@tonic-gate sub GETC { print "Don't GETC, Get Perl"; return "a"; } 664*0Sstevel@tonic-gate 665*0Sstevel@tonic-gate=item DESTROY this 666*0Sstevel@tonic-gate 667*0Sstevel@tonic-gateAs with the other types of ties, this method will be called when the 668*0Sstevel@tonic-gatetied handle is about to be destroyed. This is useful for debugging and 669*0Sstevel@tonic-gatepossibly for cleaning up. 670*0Sstevel@tonic-gate 671*0Sstevel@tonic-gate sub DESTROY { 672*0Sstevel@tonic-gate print "</shout>\n"; 673*0Sstevel@tonic-gate } 674*0Sstevel@tonic-gate 675*0Sstevel@tonic-gate=back 676*0Sstevel@tonic-gate 677*0Sstevel@tonic-gate=head2 Malloc enhancements 678*0Sstevel@tonic-gate 679*0Sstevel@tonic-gateIf perl is compiled with the malloc included with the perl distribution 680*0Sstevel@tonic-gate(that is, if C<perl -V:d_mymalloc> is 'define') then you can print 681*0Sstevel@tonic-gatememory statistics at runtime by running Perl thusly: 682*0Sstevel@tonic-gate 683*0Sstevel@tonic-gate env PERL_DEBUG_MSTATS=2 perl your_script_here 684*0Sstevel@tonic-gate 685*0Sstevel@tonic-gateThe value of 2 means to print statistics after compilation and on 686*0Sstevel@tonic-gateexit; with a value of 1, the statistics are printed only on exit. 687*0Sstevel@tonic-gate(If you want the statistics at an arbitrary time, you'll need to 688*0Sstevel@tonic-gateinstall the optional module Devel::Peek.) 689*0Sstevel@tonic-gate 690*0Sstevel@tonic-gateThree new compilation flags are recognized by malloc.c. (They have no 691*0Sstevel@tonic-gateeffect if perl is compiled with system malloc().) 692*0Sstevel@tonic-gate 693*0Sstevel@tonic-gate=over 4 694*0Sstevel@tonic-gate 695*0Sstevel@tonic-gate=item -DPERL_EMERGENCY_SBRK 696*0Sstevel@tonic-gate 697*0Sstevel@tonic-gateIf this macro is defined, running out of memory need not be a fatal 698*0Sstevel@tonic-gateerror: a memory pool can allocated by assigning to the special 699*0Sstevel@tonic-gatevariable C<$^M>. See L<"$^M">. 700*0Sstevel@tonic-gate 701*0Sstevel@tonic-gate=item -DPACK_MALLOC 702*0Sstevel@tonic-gate 703*0Sstevel@tonic-gatePerl memory allocation is by bucket with sizes close to powers of two. 704*0Sstevel@tonic-gateBecause of these malloc overhead may be big, especially for data of 705*0Sstevel@tonic-gatesize exactly a power of two. If C<PACK_MALLOC> is defined, perl uses 706*0Sstevel@tonic-gatea slightly different algorithm for small allocations (up to 64 bytes 707*0Sstevel@tonic-gatelong), which makes it possible to have overhead down to 1 byte for 708*0Sstevel@tonic-gateallocations which are powers of two (and appear quite often). 709*0Sstevel@tonic-gate 710*0Sstevel@tonic-gateExpected memory savings (with 8-byte alignment in C<alignbytes>) is 711*0Sstevel@tonic-gateabout 20% for typical Perl usage. Expected slowdown due to additional 712*0Sstevel@tonic-gatemalloc overhead is in fractions of a percent (hard to measure, because 713*0Sstevel@tonic-gateof the effect of saved memory on speed). 714*0Sstevel@tonic-gate 715*0Sstevel@tonic-gate=item -DTWO_POT_OPTIMIZE 716*0Sstevel@tonic-gate 717*0Sstevel@tonic-gateSimilarly to C<PACK_MALLOC>, this macro improves allocations of data 718*0Sstevel@tonic-gatewith size close to a power of two; but this works for big allocations 719*0Sstevel@tonic-gate(starting with 16K by default). Such allocations are typical for big 720*0Sstevel@tonic-gatehashes and special-purpose scripts, especially image processing. 721*0Sstevel@tonic-gate 722*0Sstevel@tonic-gateOn recent systems, the fact that perl requires 2M from system for 1M 723*0Sstevel@tonic-gateallocation will not affect speed of execution, since the tail of such 724*0Sstevel@tonic-gatea chunk is not going to be touched (and thus will not require real 725*0Sstevel@tonic-gatememory). However, it may result in a premature out-of-memory error. 726*0Sstevel@tonic-gateSo if you will be manipulating very large blocks with sizes close to 727*0Sstevel@tonic-gatepowers of two, it would be wise to define this macro. 728*0Sstevel@tonic-gate 729*0Sstevel@tonic-gateExpected saving of memory is 0-100% (100% in applications which 730*0Sstevel@tonic-gaterequire most memory in such 2**n chunks); expected slowdown is 731*0Sstevel@tonic-gatenegligible. 732*0Sstevel@tonic-gate 733*0Sstevel@tonic-gate=back 734*0Sstevel@tonic-gate 735*0Sstevel@tonic-gate=head2 Miscellaneous efficiency enhancements 736*0Sstevel@tonic-gate 737*0Sstevel@tonic-gateFunctions that have an empty prototype and that do nothing but return 738*0Sstevel@tonic-gatea fixed value are now inlined (e.g. C<sub PI () { 3.14159 }>). 739*0Sstevel@tonic-gate 740*0Sstevel@tonic-gateEach unique hash key is only allocated once, no matter how many hashes 741*0Sstevel@tonic-gatehave an entry with that key. So even if you have 100 copies of the 742*0Sstevel@tonic-gatesame hash, the hash keys never have to be reallocated. 743*0Sstevel@tonic-gate 744*0Sstevel@tonic-gate=head1 Support for More Operating Systems 745*0Sstevel@tonic-gate 746*0Sstevel@tonic-gateSupport for the following operating systems is new in Perl 5.004. 747*0Sstevel@tonic-gate 748*0Sstevel@tonic-gate=head2 Win32 749*0Sstevel@tonic-gate 750*0Sstevel@tonic-gatePerl 5.004 now includes support for building a "native" perl under 751*0Sstevel@tonic-gateWindows NT, using the Microsoft Visual C++ compiler (versions 2.0 752*0Sstevel@tonic-gateand above) or the Borland C++ compiler (versions 5.02 and above). 753*0Sstevel@tonic-gateThe resulting perl can be used under Windows 95 (if it 754*0Sstevel@tonic-gateis installed in the same directory locations as it got installed 755*0Sstevel@tonic-gatein Windows NT). This port includes support for perl extension 756*0Sstevel@tonic-gatebuilding tools like L<MakeMaker> and L<h2xs>, so that many extensions 757*0Sstevel@tonic-gateavailable on the Comprehensive Perl Archive Network (CPAN) can now be 758*0Sstevel@tonic-gatereadily built under Windows NT. See http://www.perl.com/ for more 759*0Sstevel@tonic-gateinformation on CPAN and F<README.win32> in the perl distribution for more 760*0Sstevel@tonic-gatedetails on how to get started with building this port. 761*0Sstevel@tonic-gate 762*0Sstevel@tonic-gateThere is also support for building perl under the Cygwin32 environment. 763*0Sstevel@tonic-gateCygwin32 is a set of GNU tools that make it possible to compile and run 764*0Sstevel@tonic-gatemany Unix programs under Windows NT by providing a mostly Unix-like 765*0Sstevel@tonic-gateinterface for compilation and execution. See F<README.cygwin32> in the 766*0Sstevel@tonic-gateperl distribution for more details on this port and how to obtain the 767*0Sstevel@tonic-gateCygwin32 toolkit. 768*0Sstevel@tonic-gate 769*0Sstevel@tonic-gate=head2 Plan 9 770*0Sstevel@tonic-gate 771*0Sstevel@tonic-gateSee F<README.plan9> in the perl distribution. 772*0Sstevel@tonic-gate 773*0Sstevel@tonic-gate=head2 QNX 774*0Sstevel@tonic-gate 775*0Sstevel@tonic-gateSee F<README.qnx> in the perl distribution. 776*0Sstevel@tonic-gate 777*0Sstevel@tonic-gate=head2 AmigaOS 778*0Sstevel@tonic-gate 779*0Sstevel@tonic-gateSee F<README.amigaos> in the perl distribution. 780*0Sstevel@tonic-gate 781*0Sstevel@tonic-gate=head1 Pragmata 782*0Sstevel@tonic-gate 783*0Sstevel@tonic-gateSix new pragmatic modules exist: 784*0Sstevel@tonic-gate 785*0Sstevel@tonic-gate=over 4 786*0Sstevel@tonic-gate 787*0Sstevel@tonic-gate=item use autouse MODULE => qw(sub1 sub2 sub3) 788*0Sstevel@tonic-gate 789*0Sstevel@tonic-gateDefers C<require MODULE> until someone calls one of the specified 790*0Sstevel@tonic-gatesubroutines (which must be exported by MODULE). This pragma should be 791*0Sstevel@tonic-gateused with caution, and only when necessary. 792*0Sstevel@tonic-gate 793*0Sstevel@tonic-gate=item use blib 794*0Sstevel@tonic-gate 795*0Sstevel@tonic-gate=item use blib 'dir' 796*0Sstevel@tonic-gate 797*0Sstevel@tonic-gateLooks for MakeMaker-like I<'blib'> directory structure starting in 798*0Sstevel@tonic-gateI<dir> (or current directory) and working back up to five levels of 799*0Sstevel@tonic-gateparent directories. 800*0Sstevel@tonic-gate 801*0Sstevel@tonic-gateIntended for use on command line with B<-M> option as a way of testing 802*0Sstevel@tonic-gatearbitrary scripts against an uninstalled version of a package. 803*0Sstevel@tonic-gate 804*0Sstevel@tonic-gate=item use constant NAME => VALUE 805*0Sstevel@tonic-gate 806*0Sstevel@tonic-gateProvides a convenient interface for creating compile-time constants, 807*0Sstevel@tonic-gateSee L<perlsub/"Constant Functions">. 808*0Sstevel@tonic-gate 809*0Sstevel@tonic-gate=item use locale 810*0Sstevel@tonic-gate 811*0Sstevel@tonic-gateTells the compiler to enable (or disable) the use of POSIX locales for 812*0Sstevel@tonic-gatebuiltin operations. 813*0Sstevel@tonic-gate 814*0Sstevel@tonic-gateWhen C<use locale> is in effect, the current LC_CTYPE locale is used 815*0Sstevel@tonic-gatefor regular expressions and case mapping; LC_COLLATE for string 816*0Sstevel@tonic-gateordering; and LC_NUMERIC for numeric formatting in printf and sprintf 817*0Sstevel@tonic-gate(but B<not> in print). LC_NUMERIC is always used in write, since 818*0Sstevel@tonic-gatelexical scoping of formats is problematic at best. 819*0Sstevel@tonic-gate 820*0Sstevel@tonic-gateEach C<use locale> or C<no locale> affects statements to the end of 821*0Sstevel@tonic-gatethe enclosing BLOCK or, if not inside a BLOCK, to the end of the 822*0Sstevel@tonic-gatecurrent file. Locales can be switched and queried with 823*0Sstevel@tonic-gatePOSIX::setlocale(). 824*0Sstevel@tonic-gate 825*0Sstevel@tonic-gateSee L<perllocale> for more information. 826*0Sstevel@tonic-gate 827*0Sstevel@tonic-gate=item use ops 828*0Sstevel@tonic-gate 829*0Sstevel@tonic-gateDisable unsafe opcodes, or any named opcodes, when compiling Perl code. 830*0Sstevel@tonic-gate 831*0Sstevel@tonic-gate=item use vmsish 832*0Sstevel@tonic-gate 833*0Sstevel@tonic-gateEnable VMS-specific language features. Currently, there are three 834*0Sstevel@tonic-gateVMS-specific features available: 'status', which makes C<$?> and 835*0Sstevel@tonic-gateC<system> return genuine VMS status values instead of emulating POSIX; 836*0Sstevel@tonic-gate'exit', which makes C<exit> take a genuine VMS status value instead of 837*0Sstevel@tonic-gateassuming that C<exit 1> is an error; and 'time', which makes all times 838*0Sstevel@tonic-gaterelative to the local time zone, in the VMS tradition. 839*0Sstevel@tonic-gate 840*0Sstevel@tonic-gate=back 841*0Sstevel@tonic-gate 842*0Sstevel@tonic-gate=head1 Modules 843*0Sstevel@tonic-gate 844*0Sstevel@tonic-gate=head2 Required Updates 845*0Sstevel@tonic-gate 846*0Sstevel@tonic-gateThough Perl 5.004 is compatible with almost all modules that work 847*0Sstevel@tonic-gatewith Perl 5.003, there are a few exceptions: 848*0Sstevel@tonic-gate 849*0Sstevel@tonic-gate Module Required Version for Perl 5.004 850*0Sstevel@tonic-gate ------ ------------------------------- 851*0Sstevel@tonic-gate Filter Filter-1.12 852*0Sstevel@tonic-gate LWP libwww-perl-5.08 853*0Sstevel@tonic-gate Tk Tk400.202 (-w makes noise) 854*0Sstevel@tonic-gate 855*0Sstevel@tonic-gateAlso, the majordomo mailing list program, version 1.94.1, doesn't work 856*0Sstevel@tonic-gatewith Perl 5.004 (nor with perl 4), because it executes an invalid 857*0Sstevel@tonic-gateregular expression. This bug is fixed in majordomo version 1.94.2. 858*0Sstevel@tonic-gate 859*0Sstevel@tonic-gate=head2 Installation directories 860*0Sstevel@tonic-gate 861*0Sstevel@tonic-gateThe I<installperl> script now places the Perl source files for 862*0Sstevel@tonic-gateextensions in the architecture-specific library directory, which is 863*0Sstevel@tonic-gatewhere the shared libraries for extensions have always been. This 864*0Sstevel@tonic-gatechange is intended to allow administrators to keep the Perl 5.004 865*0Sstevel@tonic-gatelibrary directory unchanged from a previous version, without running 866*0Sstevel@tonic-gatethe risk of binary incompatibility between extensions' Perl source and 867*0Sstevel@tonic-gateshared libraries. 868*0Sstevel@tonic-gate 869*0Sstevel@tonic-gate=head2 Module information summary 870*0Sstevel@tonic-gate 871*0Sstevel@tonic-gateBrand new modules, arranged by topic rather than strictly 872*0Sstevel@tonic-gatealphabetically: 873*0Sstevel@tonic-gate 874*0Sstevel@tonic-gate CGI.pm Web server interface ("Common Gateway Interface") 875*0Sstevel@tonic-gate CGI/Apache.pm Support for Apache's Perl module 876*0Sstevel@tonic-gate CGI/Carp.pm Log server errors with helpful context 877*0Sstevel@tonic-gate CGI/Fast.pm Support for FastCGI (persistent server process) 878*0Sstevel@tonic-gate CGI/Push.pm Support for server push 879*0Sstevel@tonic-gate CGI/Switch.pm Simple interface for multiple server types 880*0Sstevel@tonic-gate 881*0Sstevel@tonic-gate CPAN Interface to Comprehensive Perl Archive Network 882*0Sstevel@tonic-gate CPAN::FirstTime Utility for creating CPAN configuration file 883*0Sstevel@tonic-gate CPAN::Nox Runs CPAN while avoiding compiled extensions 884*0Sstevel@tonic-gate 885*0Sstevel@tonic-gate IO.pm Top-level interface to IO::* classes 886*0Sstevel@tonic-gate IO/File.pm IO::File extension Perl module 887*0Sstevel@tonic-gate IO/Handle.pm IO::Handle extension Perl module 888*0Sstevel@tonic-gate IO/Pipe.pm IO::Pipe extension Perl module 889*0Sstevel@tonic-gate IO/Seekable.pm IO::Seekable extension Perl module 890*0Sstevel@tonic-gate IO/Select.pm IO::Select extension Perl module 891*0Sstevel@tonic-gate IO/Socket.pm IO::Socket extension Perl module 892*0Sstevel@tonic-gate 893*0Sstevel@tonic-gate Opcode.pm Disable named opcodes when compiling Perl code 894*0Sstevel@tonic-gate 895*0Sstevel@tonic-gate ExtUtils/Embed.pm Utilities for embedding Perl in C programs 896*0Sstevel@tonic-gate ExtUtils/testlib.pm Fixes up @INC to use just-built extension 897*0Sstevel@tonic-gate 898*0Sstevel@tonic-gate FindBin.pm Find path of currently executing program 899*0Sstevel@tonic-gate 900*0Sstevel@tonic-gate Class/Struct.pm Declare struct-like datatypes as Perl classes 901*0Sstevel@tonic-gate File/stat.pm By-name interface to Perl's builtin stat 902*0Sstevel@tonic-gate Net/hostent.pm By-name interface to Perl's builtin gethost* 903*0Sstevel@tonic-gate Net/netent.pm By-name interface to Perl's builtin getnet* 904*0Sstevel@tonic-gate Net/protoent.pm By-name interface to Perl's builtin getproto* 905*0Sstevel@tonic-gate Net/servent.pm By-name interface to Perl's builtin getserv* 906*0Sstevel@tonic-gate Time/gmtime.pm By-name interface to Perl's builtin gmtime 907*0Sstevel@tonic-gate Time/localtime.pm By-name interface to Perl's builtin localtime 908*0Sstevel@tonic-gate Time/tm.pm Internal object for Time::{gm,local}time 909*0Sstevel@tonic-gate User/grent.pm By-name interface to Perl's builtin getgr* 910*0Sstevel@tonic-gate User/pwent.pm By-name interface to Perl's builtin getpw* 911*0Sstevel@tonic-gate 912*0Sstevel@tonic-gate Tie/RefHash.pm Base class for tied hashes with references as keys 913*0Sstevel@tonic-gate 914*0Sstevel@tonic-gate UNIVERSAL.pm Base class for *ALL* classes 915*0Sstevel@tonic-gate 916*0Sstevel@tonic-gate=head2 Fcntl 917*0Sstevel@tonic-gate 918*0Sstevel@tonic-gateNew constants in the existing Fcntl modules are now supported, 919*0Sstevel@tonic-gateprovided that your operating system happens to support them: 920*0Sstevel@tonic-gate 921*0Sstevel@tonic-gate F_GETOWN F_SETOWN 922*0Sstevel@tonic-gate O_ASYNC O_DEFER O_DSYNC O_FSYNC O_SYNC 923*0Sstevel@tonic-gate O_EXLOCK O_SHLOCK 924*0Sstevel@tonic-gate 925*0Sstevel@tonic-gateThese constants are intended for use with the Perl operators sysopen() 926*0Sstevel@tonic-gateand fcntl() and the basic database modules like SDBM_File. For the 927*0Sstevel@tonic-gateexact meaning of these and other Fcntl constants please refer to your 928*0Sstevel@tonic-gateoperating system's documentation for fcntl() and open(). 929*0Sstevel@tonic-gate 930*0Sstevel@tonic-gateIn addition, the Fcntl module now provides these constants for use 931*0Sstevel@tonic-gatewith the Perl operator flock(): 932*0Sstevel@tonic-gate 933*0Sstevel@tonic-gate LOCK_SH LOCK_EX LOCK_NB LOCK_UN 934*0Sstevel@tonic-gate 935*0Sstevel@tonic-gateThese constants are defined in all environments (because where there is 936*0Sstevel@tonic-gateno flock() system call, Perl emulates it). However, for historical 937*0Sstevel@tonic-gatereasons, these constants are not exported unless they are explicitly 938*0Sstevel@tonic-gaterequested with the ":flock" tag (e.g. C<use Fcntl ':flock'>). 939*0Sstevel@tonic-gate 940*0Sstevel@tonic-gate=head2 IO 941*0Sstevel@tonic-gate 942*0Sstevel@tonic-gateThe IO module provides a simple mechanism to load all the IO modules at one 943*0Sstevel@tonic-gatego. Currently this includes: 944*0Sstevel@tonic-gate 945*0Sstevel@tonic-gate IO::Handle 946*0Sstevel@tonic-gate IO::Seekable 947*0Sstevel@tonic-gate IO::File 948*0Sstevel@tonic-gate IO::Pipe 949*0Sstevel@tonic-gate IO::Socket 950*0Sstevel@tonic-gate 951*0Sstevel@tonic-gateFor more information on any of these modules, please see its 952*0Sstevel@tonic-gaterespective documentation. 953*0Sstevel@tonic-gate 954*0Sstevel@tonic-gate=head2 Math::Complex 955*0Sstevel@tonic-gate 956*0Sstevel@tonic-gateThe Math::Complex module has been totally rewritten, and now supports 957*0Sstevel@tonic-gatemore operations. These are overloaded: 958*0Sstevel@tonic-gate 959*0Sstevel@tonic-gate + - * / ** <=> neg ~ abs sqrt exp log sin cos atan2 "" (stringify) 960*0Sstevel@tonic-gate 961*0Sstevel@tonic-gateAnd these functions are now exported: 962*0Sstevel@tonic-gate 963*0Sstevel@tonic-gate pi i Re Im arg 964*0Sstevel@tonic-gate log10 logn ln cbrt root 965*0Sstevel@tonic-gate tan 966*0Sstevel@tonic-gate csc sec cot 967*0Sstevel@tonic-gate asin acos atan 968*0Sstevel@tonic-gate acsc asec acot 969*0Sstevel@tonic-gate sinh cosh tanh 970*0Sstevel@tonic-gate csch sech coth 971*0Sstevel@tonic-gate asinh acosh atanh 972*0Sstevel@tonic-gate acsch asech acoth 973*0Sstevel@tonic-gate cplx cplxe 974*0Sstevel@tonic-gate 975*0Sstevel@tonic-gate=head2 Math::Trig 976*0Sstevel@tonic-gate 977*0Sstevel@tonic-gateThis new module provides a simpler interface to parts of Math::Complex for 978*0Sstevel@tonic-gatethose who need trigonometric functions only for real numbers. 979*0Sstevel@tonic-gate 980*0Sstevel@tonic-gate=head2 DB_File 981*0Sstevel@tonic-gate 982*0Sstevel@tonic-gateThere have been quite a few changes made to DB_File. Here are a few of 983*0Sstevel@tonic-gatethe highlights: 984*0Sstevel@tonic-gate 985*0Sstevel@tonic-gate=over 4 986*0Sstevel@tonic-gate 987*0Sstevel@tonic-gate=item * 988*0Sstevel@tonic-gate 989*0Sstevel@tonic-gateFixed a handful of bugs. 990*0Sstevel@tonic-gate 991*0Sstevel@tonic-gate=item * 992*0Sstevel@tonic-gate 993*0Sstevel@tonic-gateBy public demand, added support for the standard hash function exists(). 994*0Sstevel@tonic-gate 995*0Sstevel@tonic-gate=item * 996*0Sstevel@tonic-gate 997*0Sstevel@tonic-gateMade it compatible with Berkeley DB 1.86. 998*0Sstevel@tonic-gate 999*0Sstevel@tonic-gate=item * 1000*0Sstevel@tonic-gate 1001*0Sstevel@tonic-gateMade negative subscripts work with RECNO interface. 1002*0Sstevel@tonic-gate 1003*0Sstevel@tonic-gate=item * 1004*0Sstevel@tonic-gate 1005*0Sstevel@tonic-gateChanged the default flags from O_RDWR to O_CREAT|O_RDWR and the default 1006*0Sstevel@tonic-gatemode from 0640 to 0666. 1007*0Sstevel@tonic-gate 1008*0Sstevel@tonic-gate=item * 1009*0Sstevel@tonic-gate 1010*0Sstevel@tonic-gateMade DB_File automatically import the open() constants (O_RDWR, 1011*0Sstevel@tonic-gateO_CREAT etc.) from Fcntl, if available. 1012*0Sstevel@tonic-gate 1013*0Sstevel@tonic-gate=item * 1014*0Sstevel@tonic-gate 1015*0Sstevel@tonic-gateUpdated documentation. 1016*0Sstevel@tonic-gate 1017*0Sstevel@tonic-gate=back 1018*0Sstevel@tonic-gate 1019*0Sstevel@tonic-gateRefer to the HISTORY section in DB_File.pm for a complete list of 1020*0Sstevel@tonic-gatechanges. Everything after DB_File 1.01 has been added since 5.003. 1021*0Sstevel@tonic-gate 1022*0Sstevel@tonic-gate=head2 Net::Ping 1023*0Sstevel@tonic-gate 1024*0Sstevel@tonic-gateMajor rewrite - support added for both udp echo and real icmp pings. 1025*0Sstevel@tonic-gate 1026*0Sstevel@tonic-gate=head2 Object-oriented overrides for builtin operators 1027*0Sstevel@tonic-gate 1028*0Sstevel@tonic-gateMany of the Perl builtins returning lists now have 1029*0Sstevel@tonic-gateobject-oriented overrides. These are: 1030*0Sstevel@tonic-gate 1031*0Sstevel@tonic-gate File::stat 1032*0Sstevel@tonic-gate Net::hostent 1033*0Sstevel@tonic-gate Net::netent 1034*0Sstevel@tonic-gate Net::protoent 1035*0Sstevel@tonic-gate Net::servent 1036*0Sstevel@tonic-gate Time::gmtime 1037*0Sstevel@tonic-gate Time::localtime 1038*0Sstevel@tonic-gate User::grent 1039*0Sstevel@tonic-gate User::pwent 1040*0Sstevel@tonic-gate 1041*0Sstevel@tonic-gateFor example, you can now say 1042*0Sstevel@tonic-gate 1043*0Sstevel@tonic-gate use File::stat; 1044*0Sstevel@tonic-gate use User::pwent; 1045*0Sstevel@tonic-gate $his = (stat($filename)->st_uid == pwent($whoever)->pw_uid); 1046*0Sstevel@tonic-gate 1047*0Sstevel@tonic-gate=head1 Utility Changes 1048*0Sstevel@tonic-gate 1049*0Sstevel@tonic-gate=head2 pod2html 1050*0Sstevel@tonic-gate 1051*0Sstevel@tonic-gate=over 4 1052*0Sstevel@tonic-gate 1053*0Sstevel@tonic-gate=item Sends converted HTML to standard output 1054*0Sstevel@tonic-gate 1055*0Sstevel@tonic-gateThe I<pod2html> utility included with Perl 5.004 is entirely new. 1056*0Sstevel@tonic-gateBy default, it sends the converted HTML to its standard output, 1057*0Sstevel@tonic-gateinstead of writing it to a file like Perl 5.003's I<pod2html> did. 1058*0Sstevel@tonic-gateUse the B<--outfile=FILENAME> option to write to a file. 1059*0Sstevel@tonic-gate 1060*0Sstevel@tonic-gate=back 1061*0Sstevel@tonic-gate 1062*0Sstevel@tonic-gate=head2 xsubpp 1063*0Sstevel@tonic-gate 1064*0Sstevel@tonic-gate=over 4 1065*0Sstevel@tonic-gate 1066*0Sstevel@tonic-gate=item C<void> XSUBs now default to returning nothing 1067*0Sstevel@tonic-gate 1068*0Sstevel@tonic-gateDue to a documentation/implementation bug in previous versions of 1069*0Sstevel@tonic-gatePerl, XSUBs with a return type of C<void> have actually been 1070*0Sstevel@tonic-gatereturning one value. Usually that value was the GV for the XSUB, 1071*0Sstevel@tonic-gatebut sometimes it was some already freed or reused value, which would 1072*0Sstevel@tonic-gatesometimes lead to program failure. 1073*0Sstevel@tonic-gate 1074*0Sstevel@tonic-gateIn Perl 5.004, if an XSUB is declared as returning C<void>, it 1075*0Sstevel@tonic-gateactually returns no value, i.e. an empty list (though there is a 1076*0Sstevel@tonic-gatebackward-compatibility exception; see below). If your XSUB really 1077*0Sstevel@tonic-gatedoes return an SV, you should give it a return type of C<SV *>. 1078*0Sstevel@tonic-gate 1079*0Sstevel@tonic-gateFor backward compatibility, I<xsubpp> tries to guess whether a 1080*0Sstevel@tonic-gateC<void> XSUB is really C<void> or if it wants to return an C<SV *>. 1081*0Sstevel@tonic-gateIt does so by examining the text of the XSUB: if I<xsubpp> finds 1082*0Sstevel@tonic-gatewhat looks like an assignment to C<ST(0)>, it assumes that the 1083*0Sstevel@tonic-gateXSUB's return type is really C<SV *>. 1084*0Sstevel@tonic-gate 1085*0Sstevel@tonic-gate=back 1086*0Sstevel@tonic-gate 1087*0Sstevel@tonic-gate=head1 C Language API Changes 1088*0Sstevel@tonic-gate 1089*0Sstevel@tonic-gate=over 4 1090*0Sstevel@tonic-gate 1091*0Sstevel@tonic-gate=item C<gv_fetchmethod> and C<perl_call_sv> 1092*0Sstevel@tonic-gate 1093*0Sstevel@tonic-gateThe C<gv_fetchmethod> function finds a method for an object, just like 1094*0Sstevel@tonic-gatein Perl 5.003. The GV it returns may be a method cache entry. 1095*0Sstevel@tonic-gateHowever, in Perl 5.004, method cache entries are not visible to users; 1096*0Sstevel@tonic-gatetherefore, they can no longer be passed directly to C<perl_call_sv>. 1097*0Sstevel@tonic-gateInstead, you should use the C<GvCV> macro on the GV to extract its CV, 1098*0Sstevel@tonic-gateand pass the CV to C<perl_call_sv>. 1099*0Sstevel@tonic-gate 1100*0Sstevel@tonic-gateThe most likely symptom of passing the result of C<gv_fetchmethod> to 1101*0Sstevel@tonic-gateC<perl_call_sv> is Perl's producing an "Undefined subroutine called" 1102*0Sstevel@tonic-gateerror on the I<second> call to a given method (since there is no cache 1103*0Sstevel@tonic-gateon the first call). 1104*0Sstevel@tonic-gate 1105*0Sstevel@tonic-gate=item C<perl_eval_pv> 1106*0Sstevel@tonic-gate 1107*0Sstevel@tonic-gateA new function handy for eval'ing strings of Perl code inside C code. 1108*0Sstevel@tonic-gateThis function returns the value from the eval statement, which can 1109*0Sstevel@tonic-gatebe used instead of fetching globals from the symbol table. See 1110*0Sstevel@tonic-gateL<perlguts>, L<perlembed> and L<perlcall> for details and examples. 1111*0Sstevel@tonic-gate 1112*0Sstevel@tonic-gate=item Extended API for manipulating hashes 1113*0Sstevel@tonic-gate 1114*0Sstevel@tonic-gateInternal handling of hash keys has changed. The old hashtable API is 1115*0Sstevel@tonic-gatestill fully supported, and will likely remain so. The additions to the 1116*0Sstevel@tonic-gateAPI allow passing keys as C<SV*>s, so that C<tied> hashes can be given 1117*0Sstevel@tonic-gatereal scalars as keys rather than plain strings (nontied hashes still 1118*0Sstevel@tonic-gatecan only use strings as keys). New extensions must use the new hash 1119*0Sstevel@tonic-gateaccess functions and macros if they wish to use C<SV*> keys. These 1120*0Sstevel@tonic-gateadditions also make it feasible to manipulate C<HE*>s (hash entries), 1121*0Sstevel@tonic-gatewhich can be more efficient. See L<perlguts> for details. 1122*0Sstevel@tonic-gate 1123*0Sstevel@tonic-gate=back 1124*0Sstevel@tonic-gate 1125*0Sstevel@tonic-gate=head1 Documentation Changes 1126*0Sstevel@tonic-gate 1127*0Sstevel@tonic-gateMany of the base and library pods were updated. These 1128*0Sstevel@tonic-gatenew pods are included in section 1: 1129*0Sstevel@tonic-gate 1130*0Sstevel@tonic-gate=over 4 1131*0Sstevel@tonic-gate 1132*0Sstevel@tonic-gate=item L<perldelta> 1133*0Sstevel@tonic-gate 1134*0Sstevel@tonic-gateThis document. 1135*0Sstevel@tonic-gate 1136*0Sstevel@tonic-gate=item L<perlfaq> 1137*0Sstevel@tonic-gate 1138*0Sstevel@tonic-gateFrequently asked questions. 1139*0Sstevel@tonic-gate 1140*0Sstevel@tonic-gate=item L<perllocale> 1141*0Sstevel@tonic-gate 1142*0Sstevel@tonic-gateLocale support (internationalization and localization). 1143*0Sstevel@tonic-gate 1144*0Sstevel@tonic-gate=item L<perltoot> 1145*0Sstevel@tonic-gate 1146*0Sstevel@tonic-gateTutorial on Perl OO programming. 1147*0Sstevel@tonic-gate 1148*0Sstevel@tonic-gate=item L<perlapio> 1149*0Sstevel@tonic-gate 1150*0Sstevel@tonic-gatePerl internal IO abstraction interface. 1151*0Sstevel@tonic-gate 1152*0Sstevel@tonic-gate=item L<perlmodlib> 1153*0Sstevel@tonic-gate 1154*0Sstevel@tonic-gatePerl module library and recommended practice for module creation. 1155*0Sstevel@tonic-gateExtracted from L<perlmod> (which is much smaller as a result). 1156*0Sstevel@tonic-gate 1157*0Sstevel@tonic-gate=item L<perldebug> 1158*0Sstevel@tonic-gate 1159*0Sstevel@tonic-gateAlthough not new, this has been massively updated. 1160*0Sstevel@tonic-gate 1161*0Sstevel@tonic-gate=item L<perlsec> 1162*0Sstevel@tonic-gate 1163*0Sstevel@tonic-gateAlthough not new, this has been massively updated. 1164*0Sstevel@tonic-gate 1165*0Sstevel@tonic-gate=back 1166*0Sstevel@tonic-gate 1167*0Sstevel@tonic-gate=head1 New Diagnostics 1168*0Sstevel@tonic-gate 1169*0Sstevel@tonic-gateSeveral new conditions will trigger warnings that were 1170*0Sstevel@tonic-gatesilent before. Some only affect certain platforms. 1171*0Sstevel@tonic-gateThe following new warnings and errors outline these. 1172*0Sstevel@tonic-gateThese messages are classified as follows (listed in 1173*0Sstevel@tonic-gateincreasing order of desperation): 1174*0Sstevel@tonic-gate 1175*0Sstevel@tonic-gate (W) A warning (optional). 1176*0Sstevel@tonic-gate (D) A deprecation (optional). 1177*0Sstevel@tonic-gate (S) A severe warning (mandatory). 1178*0Sstevel@tonic-gate (F) A fatal error (trappable). 1179*0Sstevel@tonic-gate (P) An internal error you should never see (trappable). 1180*0Sstevel@tonic-gate (X) A very fatal error (nontrappable). 1181*0Sstevel@tonic-gate (A) An alien error message (not generated by Perl). 1182*0Sstevel@tonic-gate 1183*0Sstevel@tonic-gate=over 4 1184*0Sstevel@tonic-gate 1185*0Sstevel@tonic-gate=item "my" variable %s masks earlier declaration in same scope 1186*0Sstevel@tonic-gate 1187*0Sstevel@tonic-gate(W) A lexical variable has been redeclared in the same scope, effectively 1188*0Sstevel@tonic-gateeliminating all access to the previous instance. This is almost always 1189*0Sstevel@tonic-gatea typographical error. Note that the earlier variable will still exist 1190*0Sstevel@tonic-gateuntil the end of the scope or until all closure referents to it are 1191*0Sstevel@tonic-gatedestroyed. 1192*0Sstevel@tonic-gate 1193*0Sstevel@tonic-gate=item %s argument is not a HASH element or slice 1194*0Sstevel@tonic-gate 1195*0Sstevel@tonic-gate(F) The argument to delete() must be either a hash element, such as 1196*0Sstevel@tonic-gate 1197*0Sstevel@tonic-gate $foo{$bar} 1198*0Sstevel@tonic-gate $ref->[12]->{"susie"} 1199*0Sstevel@tonic-gate 1200*0Sstevel@tonic-gateor a hash slice, such as 1201*0Sstevel@tonic-gate 1202*0Sstevel@tonic-gate @foo{$bar, $baz, $xyzzy} 1203*0Sstevel@tonic-gate @{$ref->[12]}{"susie", "queue"} 1204*0Sstevel@tonic-gate 1205*0Sstevel@tonic-gate=item Allocation too large: %lx 1206*0Sstevel@tonic-gate 1207*0Sstevel@tonic-gate(X) You can't allocate more than 64K on an MS-DOS machine. 1208*0Sstevel@tonic-gate 1209*0Sstevel@tonic-gate=item Allocation too large 1210*0Sstevel@tonic-gate 1211*0Sstevel@tonic-gate(F) You can't allocate more than 2^31+"small amount" bytes. 1212*0Sstevel@tonic-gate 1213*0Sstevel@tonic-gate=item Applying %s to %s will act on scalar(%s) 1214*0Sstevel@tonic-gate 1215*0Sstevel@tonic-gate(W) The pattern match (//), substitution (s///), and transliteration (tr///) 1216*0Sstevel@tonic-gateoperators work on scalar values. If you apply one of them to an array 1217*0Sstevel@tonic-gateor a hash, it will convert the array or hash to a scalar value -- the 1218*0Sstevel@tonic-gatelength of an array, or the population info of a hash -- and then work on 1219*0Sstevel@tonic-gatethat scalar value. This is probably not what you meant to do. See 1220*0Sstevel@tonic-gateL<perlfunc/grep> and L<perlfunc/map> for alternatives. 1221*0Sstevel@tonic-gate 1222*0Sstevel@tonic-gate=item Attempt to free nonexistent shared string 1223*0Sstevel@tonic-gate 1224*0Sstevel@tonic-gate(P) Perl maintains a reference counted internal table of strings to 1225*0Sstevel@tonic-gateoptimize the storage and access of hash keys and other strings. This 1226*0Sstevel@tonic-gateindicates someone tried to decrement the reference count of a string 1227*0Sstevel@tonic-gatethat can no longer be found in the table. 1228*0Sstevel@tonic-gate 1229*0Sstevel@tonic-gate=item Attempt to use reference as lvalue in substr 1230*0Sstevel@tonic-gate 1231*0Sstevel@tonic-gate(W) You supplied a reference as the first argument to substr() used 1232*0Sstevel@tonic-gateas an lvalue, which is pretty strange. Perhaps you forgot to 1233*0Sstevel@tonic-gatedereference it first. See L<perlfunc/substr>. 1234*0Sstevel@tonic-gate 1235*0Sstevel@tonic-gate=item Bareword "%s" refers to nonexistent package 1236*0Sstevel@tonic-gate 1237*0Sstevel@tonic-gate(W) You used a qualified bareword of the form C<Foo::>, but 1238*0Sstevel@tonic-gatethe compiler saw no other uses of that namespace before that point. 1239*0Sstevel@tonic-gatePerhaps you need to predeclare a package? 1240*0Sstevel@tonic-gate 1241*0Sstevel@tonic-gate=item Can't redefine active sort subroutine %s 1242*0Sstevel@tonic-gate 1243*0Sstevel@tonic-gate(F) Perl optimizes the internal handling of sort subroutines and keeps 1244*0Sstevel@tonic-gatepointers into them. You tried to redefine one such sort subroutine when it 1245*0Sstevel@tonic-gatewas currently active, which is not allowed. If you really want to do 1246*0Sstevel@tonic-gatethis, you should write C<sort { &func } @x> instead of C<sort func @x>. 1247*0Sstevel@tonic-gate 1248*0Sstevel@tonic-gate=item Can't use bareword ("%s") as %s ref while "strict refs" in use 1249*0Sstevel@tonic-gate 1250*0Sstevel@tonic-gate(F) Only hard references are allowed by "strict refs". Symbolic references 1251*0Sstevel@tonic-gateare disallowed. See L<perlref>. 1252*0Sstevel@tonic-gate 1253*0Sstevel@tonic-gate=item Cannot resolve method `%s' overloading `%s' in package `%s' 1254*0Sstevel@tonic-gate 1255*0Sstevel@tonic-gate(P) Internal error trying to resolve overloading specified by a method 1256*0Sstevel@tonic-gatename (as opposed to a subroutine reference). 1257*0Sstevel@tonic-gate 1258*0Sstevel@tonic-gate=item Constant subroutine %s redefined 1259*0Sstevel@tonic-gate 1260*0Sstevel@tonic-gate(S) You redefined a subroutine which had previously been eligible for 1261*0Sstevel@tonic-gateinlining. See L<perlsub/"Constant Functions"> for commentary and 1262*0Sstevel@tonic-gateworkarounds. 1263*0Sstevel@tonic-gate 1264*0Sstevel@tonic-gate=item Constant subroutine %s undefined 1265*0Sstevel@tonic-gate 1266*0Sstevel@tonic-gate(S) You undefined a subroutine which had previously been eligible for 1267*0Sstevel@tonic-gateinlining. See L<perlsub/"Constant Functions"> for commentary and 1268*0Sstevel@tonic-gateworkarounds. 1269*0Sstevel@tonic-gate 1270*0Sstevel@tonic-gate=item Copy method did not return a reference 1271*0Sstevel@tonic-gate 1272*0Sstevel@tonic-gate(F) The method which overloads "=" is buggy. See L<overload/Copy Constructor>. 1273*0Sstevel@tonic-gate 1274*0Sstevel@tonic-gate=item Died 1275*0Sstevel@tonic-gate 1276*0Sstevel@tonic-gate(F) You passed die() an empty string (the equivalent of C<die "">) or 1277*0Sstevel@tonic-gateyou called it with no args and both C<$@> and C<$_> were empty. 1278*0Sstevel@tonic-gate 1279*0Sstevel@tonic-gate=item Exiting pseudo-block via %s 1280*0Sstevel@tonic-gate 1281*0Sstevel@tonic-gate(W) You are exiting a rather special block construct (like a sort block or 1282*0Sstevel@tonic-gatesubroutine) by unconventional means, such as a goto, or a loop control 1283*0Sstevel@tonic-gatestatement. See L<perlfunc/sort>. 1284*0Sstevel@tonic-gate 1285*0Sstevel@tonic-gate=item Identifier too long 1286*0Sstevel@tonic-gate 1287*0Sstevel@tonic-gate(F) Perl limits identifiers (names for variables, functions, etc.) to 1288*0Sstevel@tonic-gate252 characters for simple names, somewhat more for compound names (like 1289*0Sstevel@tonic-gateC<$A::B>). You've exceeded Perl's limits. Future versions of Perl are 1290*0Sstevel@tonic-gatelikely to eliminate these arbitrary limitations. 1291*0Sstevel@tonic-gate 1292*0Sstevel@tonic-gate=item Illegal character %s (carriage return) 1293*0Sstevel@tonic-gate 1294*0Sstevel@tonic-gate(F) A carriage return character was found in the input. This is an 1295*0Sstevel@tonic-gateerror, and not a warning, because carriage return characters can break 1296*0Sstevel@tonic-gatemulti-line strings, including here documents (e.g., C<print <<EOF;>). 1297*0Sstevel@tonic-gate 1298*0Sstevel@tonic-gate=item Illegal switch in PERL5OPT: %s 1299*0Sstevel@tonic-gate 1300*0Sstevel@tonic-gate(X) The PERL5OPT environment variable may only be used to set the 1301*0Sstevel@tonic-gatefollowing switches: B<-[DIMUdmw]>. 1302*0Sstevel@tonic-gate 1303*0Sstevel@tonic-gate=item Integer overflow in hex number 1304*0Sstevel@tonic-gate 1305*0Sstevel@tonic-gate(S) The literal hex number you have specified is too big for your 1306*0Sstevel@tonic-gatearchitecture. On a 32-bit architecture the largest hex literal is 1307*0Sstevel@tonic-gate0xFFFFFFFF. 1308*0Sstevel@tonic-gate 1309*0Sstevel@tonic-gate=item Integer overflow in octal number 1310*0Sstevel@tonic-gate 1311*0Sstevel@tonic-gate(S) The literal octal number you have specified is too big for your 1312*0Sstevel@tonic-gatearchitecture. On a 32-bit architecture the largest octal literal is 1313*0Sstevel@tonic-gate037777777777. 1314*0Sstevel@tonic-gate 1315*0Sstevel@tonic-gate=item internal error: glob failed 1316*0Sstevel@tonic-gate 1317*0Sstevel@tonic-gate(P) Something went wrong with the external program(s) used for C<glob> 1318*0Sstevel@tonic-gateand C<< <*.c> >>. This may mean that your csh (C shell) is 1319*0Sstevel@tonic-gatebroken. If so, you should change all of the csh-related variables in 1320*0Sstevel@tonic-gateconfig.sh: If you have tcsh, make the variables refer to it as if it 1321*0Sstevel@tonic-gatewere csh (e.g. C<full_csh='/usr/bin/tcsh'>); otherwise, make them all 1322*0Sstevel@tonic-gateempty (except that C<d_csh> should be C<'undef'>) so that Perl will 1323*0Sstevel@tonic-gatethink csh is missing. In either case, after editing config.sh, run 1324*0Sstevel@tonic-gateC<./Configure -S> and rebuild Perl. 1325*0Sstevel@tonic-gate 1326*0Sstevel@tonic-gate=item Invalid conversion in %s: "%s" 1327*0Sstevel@tonic-gate 1328*0Sstevel@tonic-gate(W) Perl does not understand the given format conversion. 1329*0Sstevel@tonic-gateSee L<perlfunc/sprintf>. 1330*0Sstevel@tonic-gate 1331*0Sstevel@tonic-gate=item Invalid type in pack: '%s' 1332*0Sstevel@tonic-gate 1333*0Sstevel@tonic-gate(F) The given character is not a valid pack type. See L<perlfunc/pack>. 1334*0Sstevel@tonic-gate 1335*0Sstevel@tonic-gate=item Invalid type in unpack: '%s' 1336*0Sstevel@tonic-gate 1337*0Sstevel@tonic-gate(F) The given character is not a valid unpack type. See L<perlfunc/unpack>. 1338*0Sstevel@tonic-gate 1339*0Sstevel@tonic-gate=item Name "%s::%s" used only once: possible typo 1340*0Sstevel@tonic-gate 1341*0Sstevel@tonic-gate(W) Typographical errors often show up as unique variable names. 1342*0Sstevel@tonic-gateIf you had a good reason for having a unique name, then just mention 1343*0Sstevel@tonic-gateit again somehow to suppress the message (the C<use vars> pragma is 1344*0Sstevel@tonic-gateprovided for just this purpose). 1345*0Sstevel@tonic-gate 1346*0Sstevel@tonic-gate=item Null picture in formline 1347*0Sstevel@tonic-gate 1348*0Sstevel@tonic-gate(F) The first argument to formline must be a valid format picture 1349*0Sstevel@tonic-gatespecification. It was found to be empty, which probably means you 1350*0Sstevel@tonic-gatesupplied it an uninitialized value. See L<perlform>. 1351*0Sstevel@tonic-gate 1352*0Sstevel@tonic-gate=item Offset outside string 1353*0Sstevel@tonic-gate 1354*0Sstevel@tonic-gate(F) You tried to do a read/write/send/recv operation with an offset 1355*0Sstevel@tonic-gatepointing outside the buffer. This is difficult to imagine. 1356*0Sstevel@tonic-gateThe sole exception to this is that C<sysread()>ing past the buffer 1357*0Sstevel@tonic-gatewill extend the buffer and zero pad the new area. 1358*0Sstevel@tonic-gate 1359*0Sstevel@tonic-gate=item Out of memory! 1360*0Sstevel@tonic-gate 1361*0Sstevel@tonic-gate(X|F) The malloc() function returned 0, indicating there was insufficient 1362*0Sstevel@tonic-gateremaining memory (or virtual memory) to satisfy the request. 1363*0Sstevel@tonic-gate 1364*0Sstevel@tonic-gateThe request was judged to be small, so the possibility to trap it 1365*0Sstevel@tonic-gatedepends on the way Perl was compiled. By default it is not trappable. 1366*0Sstevel@tonic-gateHowever, if compiled for this, Perl may use the contents of C<$^M> as 1367*0Sstevel@tonic-gatean emergency pool after die()ing with this message. In this case the 1368*0Sstevel@tonic-gateerror is trappable I<once>. 1369*0Sstevel@tonic-gate 1370*0Sstevel@tonic-gate=item Out of memory during request for %s 1371*0Sstevel@tonic-gate 1372*0Sstevel@tonic-gate(F) The malloc() function returned 0, indicating there was insufficient 1373*0Sstevel@tonic-gateremaining memory (or virtual memory) to satisfy the request. However, 1374*0Sstevel@tonic-gatethe request was judged large enough (compile-time default is 64K), so 1375*0Sstevel@tonic-gatea possibility to shut down by trapping this error is granted. 1376*0Sstevel@tonic-gate 1377*0Sstevel@tonic-gate=item panic: frexp 1378*0Sstevel@tonic-gate 1379*0Sstevel@tonic-gate(P) The library function frexp() failed, making printf("%f") impossible. 1380*0Sstevel@tonic-gate 1381*0Sstevel@tonic-gate=item Possible attempt to put comments in qw() list 1382*0Sstevel@tonic-gate 1383*0Sstevel@tonic-gate(W) qw() lists contain items separated by whitespace; as with literal 1384*0Sstevel@tonic-gatestrings, comment characters are not ignored, but are instead treated 1385*0Sstevel@tonic-gateas literal data. (You may have used different delimiters than the 1386*0Sstevel@tonic-gateparentheses shown here; braces are also frequently used.) 1387*0Sstevel@tonic-gate 1388*0Sstevel@tonic-gateYou probably wrote something like this: 1389*0Sstevel@tonic-gate 1390*0Sstevel@tonic-gate @list = qw( 1391*0Sstevel@tonic-gate a # a comment 1392*0Sstevel@tonic-gate b # another comment 1393*0Sstevel@tonic-gate ); 1394*0Sstevel@tonic-gate 1395*0Sstevel@tonic-gatewhen you should have written this: 1396*0Sstevel@tonic-gate 1397*0Sstevel@tonic-gate @list = qw( 1398*0Sstevel@tonic-gate a 1399*0Sstevel@tonic-gate b 1400*0Sstevel@tonic-gate ); 1401*0Sstevel@tonic-gate 1402*0Sstevel@tonic-gateIf you really want comments, build your list the 1403*0Sstevel@tonic-gateold-fashioned way, with quotes and commas: 1404*0Sstevel@tonic-gate 1405*0Sstevel@tonic-gate @list = ( 1406*0Sstevel@tonic-gate 'a', # a comment 1407*0Sstevel@tonic-gate 'b', # another comment 1408*0Sstevel@tonic-gate ); 1409*0Sstevel@tonic-gate 1410*0Sstevel@tonic-gate=item Possible attempt to separate words with commas 1411*0Sstevel@tonic-gate 1412*0Sstevel@tonic-gate(W) qw() lists contain items separated by whitespace; therefore commas 1413*0Sstevel@tonic-gatearen't needed to separate the items. (You may have used different 1414*0Sstevel@tonic-gatedelimiters than the parentheses shown here; braces are also frequently 1415*0Sstevel@tonic-gateused.) 1416*0Sstevel@tonic-gate 1417*0Sstevel@tonic-gateYou probably wrote something like this: 1418*0Sstevel@tonic-gate 1419*0Sstevel@tonic-gate qw! a, b, c !; 1420*0Sstevel@tonic-gate 1421*0Sstevel@tonic-gatewhich puts literal commas into some of the list items. Write it without 1422*0Sstevel@tonic-gatecommas if you don't want them to appear in your data: 1423*0Sstevel@tonic-gate 1424*0Sstevel@tonic-gate qw! a b c !; 1425*0Sstevel@tonic-gate 1426*0Sstevel@tonic-gate=item Scalar value @%s{%s} better written as $%s{%s} 1427*0Sstevel@tonic-gate 1428*0Sstevel@tonic-gate(W) You've used a hash slice (indicated by @) to select a single element of 1429*0Sstevel@tonic-gatea hash. Generally it's better to ask for a scalar value (indicated by $). 1430*0Sstevel@tonic-gateThe difference is that C<$foo{&bar}> always behaves like a scalar, both when 1431*0Sstevel@tonic-gateassigning to it and when evaluating its argument, while C<@foo{&bar}> behaves 1432*0Sstevel@tonic-gatelike a list when you assign to it, and provides a list context to its 1433*0Sstevel@tonic-gatesubscript, which can do weird things if you're expecting only one subscript. 1434*0Sstevel@tonic-gate 1435*0Sstevel@tonic-gate=item Stub found while resolving method `%s' overloading `%s' in %s 1436*0Sstevel@tonic-gate 1437*0Sstevel@tonic-gate(P) Overloading resolution over @ISA tree may be broken by importing stubs. 1438*0Sstevel@tonic-gateStubs should never be implicitly created, but explicit calls to C<can> 1439*0Sstevel@tonic-gatemay break this. 1440*0Sstevel@tonic-gate 1441*0Sstevel@tonic-gate=item Too late for "B<-T>" option 1442*0Sstevel@tonic-gate 1443*0Sstevel@tonic-gate(X) The #! line (or local equivalent) in a Perl script contains the 1444*0Sstevel@tonic-gateB<-T> option, but Perl was not invoked with B<-T> in its argument 1445*0Sstevel@tonic-gatelist. This is an error because, by the time Perl discovers a B<-T> in 1446*0Sstevel@tonic-gatea script, it's too late to properly taint everything from the 1447*0Sstevel@tonic-gateenvironment. So Perl gives up. 1448*0Sstevel@tonic-gate 1449*0Sstevel@tonic-gate=item untie attempted while %d inner references still exist 1450*0Sstevel@tonic-gate 1451*0Sstevel@tonic-gate(W) A copy of the object returned from C<tie> (or C<tied>) was still 1452*0Sstevel@tonic-gatevalid when C<untie> was called. 1453*0Sstevel@tonic-gate 1454*0Sstevel@tonic-gate=item Unrecognized character %s 1455*0Sstevel@tonic-gate 1456*0Sstevel@tonic-gate(F) The Perl parser has no idea what to do with the specified character 1457*0Sstevel@tonic-gatein your Perl script (or eval). Perhaps you tried to run a compressed 1458*0Sstevel@tonic-gatescript, a binary program, or a directory as a Perl program. 1459*0Sstevel@tonic-gate 1460*0Sstevel@tonic-gate=item Unsupported function fork 1461*0Sstevel@tonic-gate 1462*0Sstevel@tonic-gate(F) Your version of executable does not support forking. 1463*0Sstevel@tonic-gate 1464*0Sstevel@tonic-gateNote that under some systems, like OS/2, there may be different flavors of 1465*0Sstevel@tonic-gatePerl executables, some of which may support fork, some not. Try changing 1466*0Sstevel@tonic-gatethe name you call Perl by to C<perl_>, C<perl__>, and so on. 1467*0Sstevel@tonic-gate 1468*0Sstevel@tonic-gate=item Use of "$$<digit>" to mean "${$}<digit>" is deprecated 1469*0Sstevel@tonic-gate 1470*0Sstevel@tonic-gate(D) Perl versions before 5.004 misinterpreted any type marker followed 1471*0Sstevel@tonic-gateby "$" and a digit. For example, "$$0" was incorrectly taken to mean 1472*0Sstevel@tonic-gate"${$}0" instead of "${$0}". This bug is (mostly) fixed in Perl 5.004. 1473*0Sstevel@tonic-gate 1474*0Sstevel@tonic-gateHowever, the developers of Perl 5.004 could not fix this bug completely, 1475*0Sstevel@tonic-gatebecause at least two widely-used modules depend on the old meaning of 1476*0Sstevel@tonic-gate"$$0" in a string. So Perl 5.004 still interprets "$$<digit>" in the 1477*0Sstevel@tonic-gateold (broken) way inside strings; but it generates this message as a 1478*0Sstevel@tonic-gatewarning. And in Perl 5.005, this special treatment will cease. 1479*0Sstevel@tonic-gate 1480*0Sstevel@tonic-gate=item Value of %s can be "0"; test with defined() 1481*0Sstevel@tonic-gate 1482*0Sstevel@tonic-gate(W) In a conditional expression, you used <HANDLE>, <*> (glob), C<each()>, 1483*0Sstevel@tonic-gateor C<readdir()> as a boolean value. Each of these constructs can return a 1484*0Sstevel@tonic-gatevalue of "0"; that would make the conditional expression false, which is 1485*0Sstevel@tonic-gateprobably not what you intended. When using these constructs in conditional 1486*0Sstevel@tonic-gateexpressions, test their values with the C<defined> operator. 1487*0Sstevel@tonic-gate 1488*0Sstevel@tonic-gate=item Variable "%s" may be unavailable 1489*0Sstevel@tonic-gate 1490*0Sstevel@tonic-gate(W) An inner (nested) I<anonymous> subroutine is inside a I<named> 1491*0Sstevel@tonic-gatesubroutine, and outside that is another subroutine; and the anonymous 1492*0Sstevel@tonic-gate(innermost) subroutine is referencing a lexical variable defined in 1493*0Sstevel@tonic-gatethe outermost subroutine. For example: 1494*0Sstevel@tonic-gate 1495*0Sstevel@tonic-gate sub outermost { my $a; sub middle { sub { $a } } } 1496*0Sstevel@tonic-gate 1497*0Sstevel@tonic-gateIf the anonymous subroutine is called or referenced (directly or 1498*0Sstevel@tonic-gateindirectly) from the outermost subroutine, it will share the variable 1499*0Sstevel@tonic-gateas you would expect. But if the anonymous subroutine is called or 1500*0Sstevel@tonic-gatereferenced when the outermost subroutine is not active, it will see 1501*0Sstevel@tonic-gatethe value of the shared variable as it was before and during the 1502*0Sstevel@tonic-gate*first* call to the outermost subroutine, which is probably not what 1503*0Sstevel@tonic-gateyou want. 1504*0Sstevel@tonic-gate 1505*0Sstevel@tonic-gateIn these circumstances, it is usually best to make the middle 1506*0Sstevel@tonic-gatesubroutine anonymous, using the C<sub {}> syntax. Perl has specific 1507*0Sstevel@tonic-gatesupport for shared variables in nested anonymous subroutines; a named 1508*0Sstevel@tonic-gatesubroutine in between interferes with this feature. 1509*0Sstevel@tonic-gate 1510*0Sstevel@tonic-gate=item Variable "%s" will not stay shared 1511*0Sstevel@tonic-gate 1512*0Sstevel@tonic-gate(W) An inner (nested) I<named> subroutine is referencing a lexical 1513*0Sstevel@tonic-gatevariable defined in an outer subroutine. 1514*0Sstevel@tonic-gate 1515*0Sstevel@tonic-gateWhen the inner subroutine is called, it will probably see the value of 1516*0Sstevel@tonic-gatethe outer subroutine's variable as it was before and during the 1517*0Sstevel@tonic-gate*first* call to the outer subroutine; in this case, after the first 1518*0Sstevel@tonic-gatecall to the outer subroutine is complete, the inner and outer 1519*0Sstevel@tonic-gatesubroutines will no longer share a common value for the variable. In 1520*0Sstevel@tonic-gateother words, the variable will no longer be shared. 1521*0Sstevel@tonic-gate 1522*0Sstevel@tonic-gateFurthermore, if the outer subroutine is anonymous and references a 1523*0Sstevel@tonic-gatelexical variable outside itself, then the outer and inner subroutines 1524*0Sstevel@tonic-gatewill I<never> share the given variable. 1525*0Sstevel@tonic-gate 1526*0Sstevel@tonic-gateThis problem can usually be solved by making the inner subroutine 1527*0Sstevel@tonic-gateanonymous, using the C<sub {}> syntax. When inner anonymous subs that 1528*0Sstevel@tonic-gatereference variables in outer subroutines are called or referenced, 1529*0Sstevel@tonic-gatethey are automatically rebound to the current values of such 1530*0Sstevel@tonic-gatevariables. 1531*0Sstevel@tonic-gate 1532*0Sstevel@tonic-gate=item Warning: something's wrong 1533*0Sstevel@tonic-gate 1534*0Sstevel@tonic-gate(W) You passed warn() an empty string (the equivalent of C<warn "">) or 1535*0Sstevel@tonic-gateyou called it with no args and C<$_> was empty. 1536*0Sstevel@tonic-gate 1537*0Sstevel@tonic-gate=item Ill-formed logical name |%s| in prime_env_iter 1538*0Sstevel@tonic-gate 1539*0Sstevel@tonic-gate(W) A warning peculiar to VMS. A logical name was encountered when preparing 1540*0Sstevel@tonic-gateto iterate over %ENV which violates the syntactic rules governing logical 1541*0Sstevel@tonic-gatenames. Since it cannot be translated normally, it is skipped, and will not 1542*0Sstevel@tonic-gateappear in %ENV. This may be a benign occurrence, as some software packages 1543*0Sstevel@tonic-gatemight directly modify logical name tables and introduce nonstandard names, 1544*0Sstevel@tonic-gateor it may indicate that a logical name table has been corrupted. 1545*0Sstevel@tonic-gate 1546*0Sstevel@tonic-gate=item Got an error from DosAllocMem 1547*0Sstevel@tonic-gate 1548*0Sstevel@tonic-gate(P) An error peculiar to OS/2. Most probably you're using an obsolete 1549*0Sstevel@tonic-gateversion of Perl, and this should not happen anyway. 1550*0Sstevel@tonic-gate 1551*0Sstevel@tonic-gate=item Malformed PERLLIB_PREFIX 1552*0Sstevel@tonic-gate 1553*0Sstevel@tonic-gate(F) An error peculiar to OS/2. PERLLIB_PREFIX should be of the form 1554*0Sstevel@tonic-gate 1555*0Sstevel@tonic-gate prefix1;prefix2 1556*0Sstevel@tonic-gate 1557*0Sstevel@tonic-gateor 1558*0Sstevel@tonic-gate 1559*0Sstevel@tonic-gate prefix1 prefix2 1560*0Sstevel@tonic-gate 1561*0Sstevel@tonic-gatewith nonempty prefix1 and prefix2. If C<prefix1> is indeed a prefix 1562*0Sstevel@tonic-gateof a builtin library search path, prefix2 is substituted. The error 1563*0Sstevel@tonic-gatemay appear if components are not found, or are too long. See 1564*0Sstevel@tonic-gate"PERLLIB_PREFIX" in F<README.os2>. 1565*0Sstevel@tonic-gate 1566*0Sstevel@tonic-gate=item PERL_SH_DIR too long 1567*0Sstevel@tonic-gate 1568*0Sstevel@tonic-gate(F) An error peculiar to OS/2. PERL_SH_DIR is the directory to find the 1569*0Sstevel@tonic-gateC<sh>-shell in. See "PERL_SH_DIR" in F<README.os2>. 1570*0Sstevel@tonic-gate 1571*0Sstevel@tonic-gate=item Process terminated by SIG%s 1572*0Sstevel@tonic-gate 1573*0Sstevel@tonic-gate(W) This is a standard message issued by OS/2 applications, while *nix 1574*0Sstevel@tonic-gateapplications die in silence. It is considered a feature of the OS/2 1575*0Sstevel@tonic-gateport. One can easily disable this by appropriate sighandlers, see 1576*0Sstevel@tonic-gateL<perlipc/"Signals">. See also "Process terminated by SIGTERM/SIGINT" 1577*0Sstevel@tonic-gatein F<README.os2>. 1578*0Sstevel@tonic-gate 1579*0Sstevel@tonic-gate=back 1580*0Sstevel@tonic-gate 1581*0Sstevel@tonic-gate=head1 BUGS 1582*0Sstevel@tonic-gate 1583*0Sstevel@tonic-gateIf you find what you think is a bug, you might check the headers of 1584*0Sstevel@tonic-gaterecently posted articles in the comp.lang.perl.misc newsgroup. 1585*0Sstevel@tonic-gateThere may also be information at http://www.perl.com/perl/ , the Perl 1586*0Sstevel@tonic-gateHome Page. 1587*0Sstevel@tonic-gate 1588*0Sstevel@tonic-gateIf you believe you have an unreported bug, please run the B<perlbug> 1589*0Sstevel@tonic-gateprogram included with your release. Make sure you trim your bug down 1590*0Sstevel@tonic-gateto a tiny but sufficient test case. Your bug report, along with the 1591*0Sstevel@tonic-gateoutput of C<perl -V>, will be sent off to <F<perlbug@perl.com>> to be 1592*0Sstevel@tonic-gateanalysed by the Perl porting team. 1593*0Sstevel@tonic-gate 1594*0Sstevel@tonic-gate=head1 SEE ALSO 1595*0Sstevel@tonic-gate 1596*0Sstevel@tonic-gateThe F<Changes> file for exhaustive details on what changed. 1597*0Sstevel@tonic-gate 1598*0Sstevel@tonic-gateThe F<INSTALL> file for how to build Perl. This file has been 1599*0Sstevel@tonic-gatesignificantly updated for 5.004, so even veteran users should 1600*0Sstevel@tonic-gatelook through it. 1601*0Sstevel@tonic-gate 1602*0Sstevel@tonic-gateThe F<README> file for general stuff. 1603*0Sstevel@tonic-gate 1604*0Sstevel@tonic-gateThe F<Copying> file for copyright information. 1605*0Sstevel@tonic-gate 1606*0Sstevel@tonic-gate=head1 HISTORY 1607*0Sstevel@tonic-gate 1608*0Sstevel@tonic-gateConstructed by Tom Christiansen, grabbing material with permission 1609*0Sstevel@tonic-gatefrom innumerable contributors, with kibitzing by more than a few Perl 1610*0Sstevel@tonic-gateporters. 1611*0Sstevel@tonic-gate 1612*0Sstevel@tonic-gateLast update: Wed May 14 11:14:09 EDT 1997 1613