Cari di Perl 
    Perl Tutorial
Daftar Isi
(Sebelumnya) What is new for perl v5.10.1What is new for perl v5.8.9 (Berikutnya)
History-Changes

What is new for perl 5.10.0

Daftar Isi

NAME

perl5100delta - what is new for perl 5.10.0

DESCRIPTION

This document describes the differences between the 5.8.8 release andthe 5.10.0 release.

Many of the bug fixes in 5.10.0 were already seen in the 5.8.X maintenancereleases; they are not duplicated here and are documented in the set ofman pages named perl58[1-8]?delta.

Core Enhancements

The feature pragma

The feature pragma is used to enable new syntax that would break Perl'sbackwards-compatibility with older releases of the language. It's a lexicalpragma, like strict or warnings.

Currently the following new features are available: switch (adds aswitch statement), say (adds a say built-in function), and state(adds a state keyword for declaring "static" variables). Thosefeatures are described in their own sections of this document.

The feature pragma is also implicitly loaded when you require a minimalperl version (with the use VERSION construct) greater than, or equalto, 5.9.5. See feature for details.

New -E command-line switch

-E is equivalent to -e, but it implicitly enables alloptional features (like use feature ":5.10").

Defined-or operator

A new operator // (defined-or) has been implemented.The following expression:

  1. $a // $b

is merely equivalent to

  1. defined $a ? $a : $b

and the statement

  1. $c //= $d;

can now be used instead of

  1. $c = $d unless defined $c;

The // operator has the same precedence and associativity as ||.Special care has been taken to ensure that this operator Do What You Meanwhile not breaking old code, but some edge cases involving the emptyregular expression may now parse differently. See perlop fordetails.

Switch and Smart Match operator

Perl 5 now has a switch statement. It's available when use feature'switch' is in effect. This feature introduces three new keywords,given, when, and default:

  1. given ($foo) {
  2. when (/^abc/) { $abc = 1; }
  3. when (/^def/) { $def = 1; }
  4. when (/^xyz/) { $xyz = 1; }
  5. default { $nothing = 1; }
  6. }

A more complete description of how Perl matches the switch variableagainst the when conditions is given in Switch statements in perlsyn.

This kind of match is called smart match, and it's also possible to useit outside of switch statements, via the new ~~ operator. SeeSmart matching in detail in perlsyn.

This feature was contributed by Robin Houston.

Regular expressions

  • Recursive Patterns

    It is now possible to write recursive patterns without using the (??{})construct. This new way is more efficient, and in many cases easier toread.

    Each capturing parenthesis can now be treated as an independent patternthat can be entered by using the (?PARNO) syntax (PARNO standing for"parenthesis number"). For example, the following pattern will matchnested balanced angle brackets:

    1. /
    2. ^ # start of line
    3. ( # start capture buffer 1
    4. < # match an opening angle bracket
    5. (?: # match one of:
    6. (?> # don't backtrack over the inside of this group
    7. [^<>]+ # one or more non angle brackets
    8. ) # end non backtracking group
    9. | # ... or ...
    10. (?1) # recurse to bracket 1 and try it again
    11. )* # 0 or more times.
    12. > # match a closing angle bracket
    13. ) # end capture buffer one
    14. $ # end of line
    15. /x

    PCRE users should note that Perl's recursive regex feature allowsbacktracking into a recursed pattern, whereas in PCRE the recursion isatomic or "possessive" in nature. As in the example above, you canadd (?>) to control this selectively. (Yves Orton)

  • Named Capture Buffers

    It is now possible to name capturing parenthesis in a pattern and refer tothe captured contents by name. The naming syntax is (?<NAME>....).It's possible to backreference to a named buffer with the \k<NAME>syntax. In code, the new magical hashes %+ and %- can be used toaccess the contents of the capture buffers.

    Thus, to replace all doubled chars with a single copy, one could write

    1. s/(?<letter>.)\k<letter>/$+{letter}/g

    Only buffers with defined contents will be "visible" in the %+ hash, soit's possible to do something like

    1. foreach my $name (keys %+) {
    2. print "content of buffer '$name' is $+{$name}\n";
    3. }

    The %- hash is a bit more complete, since it will contain array refsholding values from all capture buffers similarly named, if there shouldbe many of them.

    %+ and %- are implemented as tied hashes through the new moduleTie::Hash::NamedCapture.

    Users exposed to the .NET regex engine will find that the perlimplementation differs in that the numerical ordering of the buffersis sequential, and not "unnamed first, then named". Thus in the pattern

    1. /(A)(?<B>B)(C)(?<D>D)/

    $1 will be 'A', $2 will be 'B', $3 will be 'C' and $4 will be 'D' and not$1 is 'A', $2 is 'C' and $3 is 'B' and $4 is 'D' that a .NET programmerwould expect. This is considered a feature. :-) (Yves Orton)

  • Possessive Quantifiers

    Perl now supports the "possessive quantifier" syntax of the "atomic match"pattern. Basically a possessive quantifier matches as much as it can and nevergives any back. Thus it can be used to control backtracking. The syntax issimilar to non-greedy matching, except instead of using a '?' as the modifierthe '+' is used. Thus ?+, *+, ++, {min,max}+ are now legalquantifiers. (Yves Orton)

  • Backtracking control verbs

    The regex engine now supports a number of special-purpose backtrackcontrol verbs: (*THEN), (*PRUNE), (*MARK), (*SKIP), (*COMMIT), (*FAIL)and (*ACCEPT). See perlre for their descriptions. (Yves Orton)

  • Relative backreferences

    A new syntax \g{N} or \gN where "N" is a decimal integer allows asafer form of back-reference notation as well as allowing relativebackreferences. This should make it easier to generate and embed patternsthat contain backreferences. See Capture buffers in perlre. (Yves Orton)

  • \K escape

    The functionality of Jeff Pinyan's module Regexp::Keep has been added tothe core. In regular expressions you can now use the special escape \Kas a way to do something like floating length positive lookbehind. It isalso useful in substitutions like:

    1. s/(foo)bar/$1/g

    that can now be converted to

    1. s/foo\Kbar//g

    which is much more efficient. (Yves Orton)

  • Vertical and horizontal whitespace, and linebreak

    Regular expressions now recognize the \v and \h escapes that matchvertical and horizontal whitespace, respectively. \V and \Hlogically match their complements.

    \R matches a generic linebreak, that is, vertical whitespace, plusthe multi-character sequence "\x0D\x0A".

say()

say() is a new built-in, only available when use feature 'say' is ineffect, that is similar to print(), but that implicitly appends a newlineto the printed string. See say. (Robin Houston)

Lexical $_

The default variable $_ can now be lexicalized, by declaring it likeany other lexical variable, with a simple

  1. my $_;

The operations that default on $_ will use the lexically-scopedversion of $_ when it exists, instead of the global $_.

In a map or a grep block, if $_ was previously my'ed, then the$_ inside the block is lexical as well (and scoped to the block).

In a scope where $_ has been lexicalized, you can still have access tothe global version of $_ by using $::_, or, more simply, byoverriding the lexical declaration with our $_. (Rafael Garcia-Suarez)

The _ prototype

A new prototype character has been added. _ is equivalent to $ butdefaults to $_ if the corresponding argument isn't supplied (both $and _ denote a scalar). Due to the optional nature of the argument, you can only use it at the end of a prototype, or before a semicolon.

This has a small incompatible consequence: the prototype() function hasbeen adjusted to return _ for some built-ins in appropriate cases (forexample, prototype('CORE::rmdir')). (Rafael Garcia-Suarez)

UNITCHECK blocks

UNITCHECK, a new special code block has been introduced, in addition toBEGIN, CHECK, INIT and END.

CHECK and INIT blocks, while useful for some specialized purposes,are always executed at the transition between the compilation and theexecution of the main program, and thus are useless whenever code isloaded at runtime. On the other hand, UNITCHECK blocks are executedjust after the unit which defined them has been compiled. See perlmodfor more information. (Alex Gough)

New Pragma, mro

A new pragma, mro (for Method Resolution Order) has been added. Itpermits to switch, on a per-class basis, the algorithm that perl uses tofind inherited methods in case of a multiple inheritance hierarchy. Thedefault MRO hasn't changed (DFS, for Depth First Search). Another MRO isavailable: the C3 algorithm. See mro for more information.(Brandon Black)

Note that, due to changes in the implementation of class hierarchy search,code that used to undef the *ISA glob will most probably break. Anyway,undef'ing *ISA had the side-effect of removing the magic on the @ISAarray and should not have been done in the first place. Also, thecache *::ISA::CACHE:: no longer exists; to force reset the @ISA cache,you now need to use the mro API, or more simply to assign to @ISA(e.g. with @ISA = @ISA).

readdir() may return a "short filename" on Windows

The readdir() function may return a "short filename" when the longfilename contains characters outside the ANSI codepage. SimilarlyCwd::cwd() may return a short directory name, and glob() may return shortnames as well. On the NTFS file system these short names can always berepresented in the ANSI codepage. This will not be true for all other filesystem drivers; e.g. the FAT filesystem stores short filenames in the OEMcodepage, so some files on FAT volumes remain unaccessible through theANSI APIs.

Similarly, $^X, @INC, and $ENV{PATH} are preprocessed at startup to makesure all paths are valid in the ANSI codepage (if possible).

The Win32::GetLongPathName() function now returns the UTF-8 encodedcorrect long file name instead of using replacement characters to forcethe name into the ANSI codepage. The new Win32::GetANSIPathName()function can be used to turn a long pathname into a short one only if thelong one cannot be represented in the ANSI codepage.

Many other functions in the Win32 module have been improved to acceptUTF-8 encoded arguments. Please see Win32 for details.

readpipe() is now overridable

The built-in function readpipe() is now overridable. Overriding it permitsalso to override its operator counterpart, qx// (a.k.a. ``).Moreover, it now defaults to $_ if no argument is provided. (RafaelGarcia-Suarez)

Default argument for readline()

readline() now defaults to *ARGV if no argument is provided. (RafaelGarcia-Suarez)

state() variables

A new class of variables has been introduced. State variables are similarto my variables, but are declared with the state keyword in place ofmy. They're visible only in their lexical scope, but their value ispersistent: unlike my variables, they're not undefined at scope entry,but retain their previous value. (Rafael Garcia-Suarez, Nicholas Clark)

To use state variables, one needs to enable them by using

  1. use feature 'state';

or by using the -E command-line switch in one-liners.See Persistent Private Variables in perlsub.

Stacked filetest operators

As a new form of syntactic sugar, it's now possible to stack up filetestoperators. You can now write -f -w -x $file in a row to mean-x $file && -w _ && -f _. See -X.

UNIVERSAL::DOES()

The UNIVERSAL class has a new method, DOES(). It has been added tosolve semantic problems with the isa() method. isa() checks forinheritance, while DOES() has been designed to be overridden whenmodule authors use other types of relations between classes (in additionto inheritance). (chromatic)

See $obj->DOES( ROLE ) in UNIVERSAL.

Formats

Formats were improved in several ways. A new field, ^*, can be used forvariable-width, one-line-at-a-time text. Null characters are now handledcorrectly in picture lines. Using @# and ~~ together will nowproduce a compile-time error, as those format fields are incompatible.perlform has been improved, and miscellaneous bugs fixed.

Byte-order modifiers for pack() and unpack()

There are two new byte-order modifiers, > (big-endian) and <(little-endian), that can be appended to most pack() and unpack() templatecharacters and groups to force a certain byte-order for that type or group.See pack and perlpacktut for details.

no VERSION

You can now use no followed by a version number to specify that youwant to use a version of perl older than the specified one.

chdir, chmod and chown on filehandles

chdir, chmod and chown can now work on filehandles as well asfilenames, if the system supports respectively fchdir, fchmod andfchown, thanks to a patch provided by Gisle Aas.

OS groups

$( and $) now return groups in the order where the OS returns them,thanks to Gisle Aas. This wasn't previously the case.

Recursive sort subs

You can now use recursive subroutines with sort(), thanks to Robin Houston.

Exceptions in constant folding

The constant folding routine is now wrapped in an exception handler, andif folding throws an exception (such as attempting to evaluate 0/0), perlnow retains the current optree, rather than aborting the whole program.Without this change, programs would not compile if they had expressions thathappened to generate exceptions, even though those expressions were in codethat could never be reached at runtime. (Nicholas Clark, Dave Mitchell)

Source filters in @INC

It's possible to enhance the mechanism of subroutine hooks in @INC byadding a source filter on top of the filehandle opened and returned by thehook. This feature was planned a long time ago, but wasn't quite workinguntil now. See require for details. (Nicholas Clark)

New internal variables

  • ${^RE_DEBUG_FLAGS}

    This variable controls what debug flags are in effect for the regularexpression engine when running under use re "debug". See re fordetails.

  • ${^CHILD_ERROR_NATIVE}

    This variable gives the native status returned by the last pipe close,backtick command, successful call to wait() or waitpid(), or from thesystem() operator. See perlvar for details. (Contributed by Gisle Aas.)

  • ${^RE_TRIE_MAXBUF}

    See Trie optimisation of literal string alternations.

  • ${^WIN32_SLOPPY_STAT}

    See Sloppy stat on Windows.

Miscellaneous

unpack() now defaults to unpacking the $_ variable.

mkdir() without arguments now defaults to $_.

The internal dump output has been improved, so that non-printable characterssuch as newline and backspace are output in \x notation, rather thanoctal.

The -C option can no longer be used on the #! line. It wasn'tworking there anyway, since the standard streams are already set upat this point in the execution of the perl interpreter. You can usebinmode() instead to get the desired behaviour.

UCD 5.0.0

The copy of the Unicode Character Database included in Perl 5 hasbeen updated to version 5.0.0.

MAD

MAD, which stands for Miscellaneous Attribute Decoration, is astill-in-development work leading to a Perl 5 to Perl 6 converter. Toenable it, it's necessary to pass the argument -Dmad to Configure. Theobtained perl isn't binary compatible with a regular perl 5.10, and hasspace and speed penalties; moreover not all regression tests still passwith it. (Larry Wall, Nicholas Clark)

kill() on Windows

On Windows platforms, kill(-9, $pid) now kills a process tree.(On Unix, this delivers the signal to all processes in the same processgroup.)

Incompatible Changes

Packing and UTF-8 strings

The semantics of pack() and unpack() regarding UTF-8-encoded data has beenchanged. Processing is now by default character per character instead ofbyte per byte on the underlying encoding. Notably, code that used thingslike pack("a*", $string) to see through the encoding of string will nowsimply get back the original $string. Packed strings can also get upgradedduring processing when you store upgraded characters. You can get the oldbehaviour by using use bytes.

To be consistent with pack(), the C0 in unpack() templates indicatesthat the data is to be processed in character mode, i.e. character bycharacter; on the contrary, U0 in unpack() indicates UTF-8 mode, wherethe packed string is processed in its UTF-8-encoded Unicode form on a byteby byte basis. This is reversed with regard to perl 5.8.X, but now consistentbetween pack() and unpack().

Moreover, C0 and U0 can also be used in pack() templates to specifyrespectively character and byte modes.

C0 and U0 in the middle of a pack or unpack format now switch to thespecified encoding mode, honoring parens grouping. Previously, parens wereignored.

Also, there is a new pack() character format, W, which is intended toreplace the old C. C is kept for unsigned chars coded as bytes inthe strings internal representation. W represents unsigned (logical)character values, which can be greater than 255. It is therefore morerobust when dealing with potentially UTF-8-encoded data (as C will wrapvalues outside the range 0..255, and not respect the string encoding).

In practice, that means that pack formats are now encoding-neutral, exceptC.

For consistency, A in unpack() format now trims all Unicode whitespacefrom the end of the string. Before perl 5.9.2, it used to strip only theclassical ASCII space characters.

Byte/character count feature in unpack()

A new unpack() template character, ".", returns the number of bytes orcharacters (depending on the selected encoding mode, see above) read so far.

The $* and $# variables have been removed

$*, which was deprecated in favor of the /s and /m regexpmodifiers, has been removed.

The deprecated $# variable (output format for numbers) has beenremoved.

Two new severe warnings, $#/$* is no longer supported, have been added.

substr() lvalues are no longer fixed-length

The lvalues returned by the three argument form of substr() used to be a"fixed length window" on the original string. In some cases this couldcause surprising action at distance or other undefined behaviour. Now thelength of the window adjusts itself to the length of the string assigned toit.

Parsing of -f _

The identifier _ is now forced to be a bareword after a filetestoperator. This solves a number of misparsing issues when a global _subroutine is defined.

:unique

The :unique attribute has been made a no-op, since its currentimplementation was fundamentally flawed and not threadsafe.

Effect of pragmas in eval

The compile-time value of the %^H hint variable can now propagate intoeval("")uated code. This makes it more useful to implement lexicalpragmas.

As a side-effect of this, the overloaded-ness of constants now propagatesinto eval("").

chdir FOO

A bareword argument to chdir() is now recognized as a file handle.Earlier releases interpreted the bareword as a directory name.(Gisle Aas)

Handling of .pmc files

An old feature of perl was that before require or use look for afile with a .pm extension, they will first look for a similar filenamewith a .pmc extension. If this file is found, it will be loaded inplace of any potentially existing file ending in a .pm extension.

Previously, .pmc files were loaded only if more recent than thematching .pm file. Starting with 5.9.4, they'll be always loaded ifthey exist.

$^V is now a version object instead of a v-string

$^V can still be used with the %vd format in printf, but anycharacter-level operations will now access the string representationof the version object and not the ordinals of a v-string.Expressions like substr($^V, 0, 2) or split //, $^Vno longer work and must be rewritten.

@- and @+ in patterns

The special arrays @- and @+ are no longer interpolated in regularexpressions. (Sadahiro Tomoyuki)

$AUTOLOAD can now be tainted

If you call a subroutine by a tainted name, and if it defers to anAUTOLOAD function, then $AUTOLOAD will be (correctly) tainted.(Rick Delaney)

Tainting and printf

When perl is run under taint mode, printf() and sprintf() will nowreject any tainted format argument. (Rafael Garcia-Suarez)

undef and signal handlers

Undefining or deleting a signal handler via undef $SIG{FOO} is nowequivalent to setting it to 'DEFAULT'. (Rafael Garcia-Suarez)

strictures and dereferencing in defined()

use strict 'refs' was ignoring taking a hard reference in an argumentto defined(), as in :

  1. use strict 'refs';
  2. my $x = 'foo';
  3. if (defined $$x) {...}

This now correctly produces the run-time error Can't use string as aSCALAR ref while "strict refs" in use.

defined @$foo and defined %$bar are now also subject to strict'refs' (that is, $foo and $bar shall be proper references there.)(defined(@foo) and defined(%bar) are discouraged constructs anyway.)(Nicholas Clark)

(?p{}) has been removed

The regular expression construct (?p{}), which was deprecated in perl5.8, has been removed. Use (??{}) instead. (Rafael Garcia-Suarez)

Pseudo-hashes have been removed

Support for pseudo-hashes has been removed from Perl 5.9. (The fieldspragma remains here, but uses an alternate implementation.)

Removal of the bytecode compiler and of perlcc

perlcc, the byteloader and the supporting modules (B::C, B::CC,B::Bytecode, etc.) are no longer distributed with the perl sources. Thoseexperimental tools have never worked reliably, and, due to the lack ofvolunteers to keep them in line with the perl interpreter developments, itwas decided to remove them instead of shipping a broken version of those.The last version of those modules can be found with perl 5.9.4.

However the B compiler framework stays supported in the perl core, as withthe more useful modules it has permitted (among others, B::Deparse andB::Concise).

Removal of the JPL

The JPL (Java-Perl Lingo) has been removed from the perl sources tarball.

Recursive inheritance detected earlier

Perl will now immediately throw an exception if you modify any package's@ISA in such a way that it would cause recursive inheritance.

Previously, the exception would not occur until Perl attempted to makeuse of the recursive inheritance while resolving a method or doing a$foo->isa($bar) lookup.

warnings::enabled and warnings::warnif changed to favor users of modules

The behaviour in 5.10.x favors the person using the module;The behaviour in 5.8.x favors the module writer;

Assume the following code:

  1. main calls Foo::Bar::baz()
  2. Foo::Bar inherits from Foo::Base
  3. Foo::Bar::baz() calls Foo::Base::_bazbaz()
  4. Foo::Base::_bazbaz() calls: warnings::warnif('substr', 'some warning
  5. message');

On 5.8.x, the code warns when Foo::Bar contains use warnings;It does not matter if Foo::Base or main have warnings enabledto disable the warning one has to modify Foo::Bar.

On 5.10.0 and newer, the code warns when main contains use warnings;It does not matter if Foo::Base or Foo::Bar have warnings enabledto disable the warning one has to modify main.

Modules and Pragmata

Upgrading individual core modules

Even more core modules are now also available separately through theCPAN. If you wish to update one of these modules, you don't need towait for a new perl release. From within the cpan shell, running the'r' command will report on modules with upgrades available. Seeperldoc CPAN for more information.

Pragmata Changes

  • feature

    The new pragma feature is used to enable new features that might breakold code. See The feature pragma above.

  • mro

    This new pragma enables to change the algorithm used to resolve inheritedmethods. See New Pragma, mro above.

  • Scoping of the sort pragma

    The sort pragma is now lexically scoped. Its effect used to be global.

  • Scoping of bignum, bigint, bigrat

    The three numeric pragmas bignum, bigint and bigrat are nowlexically scoped. (Tels)

  • base

    The base pragma now warns if a class tries to inherit from itself.(Curtis "Ovid" Poe)

  • strict and warnings

    strict and warnings will now complain loudly if they are loaded viaincorrect casing (as in use Strict;). (Johan Vromans)

  • version

    The version module provides support for version objects.

  • warnings

    The warnings pragma doesn't load Carp anymore. That means that codethat used Carp routines without having loaded it at compile time mightneed to be adjusted; typically, the following (faulty) code won't workanymore, and will require parentheses to be added after the function name:

    1. use warnings;
    2. require Carp;
    3. Carp::confess 'argh';
  • less

    less now does something useful (or at least it tries to). In fact, ithas been turned into a lexical pragma. So, in your modules, you can nowtest whether your users have requested to use less CPU, or less memory,less magic, or maybe even less fat. See less for more. (Joshua benJore)

New modules

  • encoding::warnings, by Audrey Tang, is a module to emit warningswhenever an ASCII character string containing high-bit bytes is implicitlyconverted into UTF-8. It's a lexical pragma since Perl 5.9.4; on olderperls, its effect is global.

  • Module::CoreList, by Richard Clamp, is a small handy module that tellsyou what versions of core modules ship with any versions of Perl 5. Itcomes with a command-line frontend, corelist.

  • Math::BigInt::FastCalc is an XS-enabled, and thus faster, version ofMath::BigInt::Calc.

  • Compress::Zlib is an interface to the zlib compression library. Itcomes with a bundled version of zlib, so having a working zlib is not aprerequisite to install it. It's used by Archive::Tar (see below).

  • IO::Zlib is an IO::-style interface to Compress::Zlib.

  • Archive::Tar is a module to manipulate tar archives.

  • Digest::SHA is a module used to calculate many types of SHA digests,has been included for SHA support in the CPAN module.

  • ExtUtils::CBuilder and ExtUtils::ParseXS have been added.

  • Hash::Util::FieldHash, by Anno Siegel, has been added. This moduleprovides support for field hashes: hashes that maintain an associationof a reference with a value, in a thread-safe garbage-collected way.Such hashes are useful to implement inside-out objects.

  • Module::Build, by Ken Williams, has been added. It's an alternative toExtUtils::MakeMaker to build and install perl modules.

  • Module::Load, by Jos Boumans, has been added. It provides a singleinterface to load Perl modules and .pl files.

  • Module::Loaded, by Jos Boumans, has been added. It's used to markmodules as loaded or unloaded.

  • Package::Constants, by Jos Boumans, has been added. It's a simplehelper to list all constants declared in a given package.

  • Win32API::File, by Tye McQueen, has been added (for Windows builds).This module provides low-level access to Win32 system API calls forfiles/dirs.

  • Locale::Maketext::Simple, needed by CPANPLUS, is a simple wrapper aroundLocale::Maketext::Lexicon. Note that Locale::Maketext::Lexicon isn'tincluded in the perl core; the behaviour of Locale::Maketext::Simplegracefully degrades when the later isn't present.

  • Params::Check implements a generic input parsing/checking mechanism. Itis used by CPANPLUS.

  • Term::UI simplifies the task to ask questions at a terminal prompt.

  • Object::Accessor provides an interface to create per-object accessors.

  • Module::Pluggable is a simple framework to create modules that acceptpluggable sub-modules.

  • Module::Load::Conditional provides simple ways to query and possiblyload installed modules.

  • Time::Piece provides an object oriented interface to time functions,overriding the built-ins localtime() and gmtime().

  • IPC::Cmd helps to find and run external commands, possiblyinteractively.

  • File::Fetch provide a simple generic file fetching mechanism.

  • Log::Message and Log::Message::Simple are used by the log facilityof CPANPLUS.

  • Archive::Extract is a generic archive extraction mechanismfor .tar (plain, gzipped or bzipped) or .zip files.

  • CPANPLUS provides an API and a command-line tool to access the CPANmirrors.

  • Pod::Escapes provides utilities that are useful in decoding PodE<...> sequences.

  • Pod::Simple is now the backend for several of the Pod-related modulesincluded with Perl.

Selected Changes to Core Modules

  • Attribute::Handlers

    Attribute::Handlers can now report the caller's file and line number.(David Feldman)

    All interpreted attributes are now passed as array references. (DamianConway)

  • B::Lint

    B::Lint is now based on Module::Pluggable, and so can be extendedwith plugins. (Joshua ben Jore)

  • B

    It's now possible to access the lexical pragma hints (%^H) by using themethod B::COP::hints_hash(). It returns a B::RHE object, which in turncan be used to get a hash reference via the method B::RHE::HASH(). (Joshuaben Jore)

  • Thread

    As the old 5005thread threading model has been removed, in favor of theithreads scheme, the Thread module is now a compatibility wrapper, tobe used in old code only. It has been removed from the default list ofdynamic extensions.

Utility Changes

  • perl -d

    The Perl debugger can now save all debugger commands for sourcing later;notably, it can now emulate stepping backwards, by restarting andrerunning all bar the last command from a saved command history.

    It can also display the parent inheritance tree of a given class, with thei command.

  • ptar

    ptar is a pure perl implementation of tar that comes withArchive::Tar.

  • ptardiff

    ptardiff is a small utility used to generate a diff between the contentsof a tar archive and a directory tree. Like ptar, it comes withArchive::Tar.

  • shasum

    shasum is a command-line utility, used to print or to check SHAdigests. It comes with the new Digest::SHA module.

  • corelist

    The corelist utility is now installed with perl (see New modulesabove).

  • h2ph and h2xs

    h2ph and h2xs have been made more robust with regard to"modern" C code.

    h2xs implements a new option --use-xsloader to force use ofXSLoader even in backwards compatible modules.

    The handling of authors' names that had apostrophes has been fixed.

    Any enums with negative values are now skipped.

  • perlivp

    perlivp no longer checks for *.ph files by default. Use the new -aoption to run all tests.

  • find2perl

    find2perl now assumes -print as a default action. Previously, itneeded to be specified explicitly.

    Several bugs have been fixed in find2perl, regarding -exec and-eval. Also the options -path, -ipath and -iname have beenadded.

  • config_data

    config_data is a new utility that comes with Module::Build. Itprovides a command-line interface to the configuration of Perl modulesthat use Module::Build's framework of configurability (that is,*::ConfigData modules that contain local configuration information fortheir parent modules.)

  • cpanp

    cpanp, the CPANPLUS shell, has been added. (cpanp-run-perl, ahelper for CPANPLUS operation, has been added too, but isn't intended fordirect use).

  • cpan2dist

    cpan2dist is a new utility that comes with CPANPLUS. It's a tool tocreate distributions (or packages) from CPAN modules.

  • pod2html

    The output of pod2html has been enhanced to be more customizable viaCSS. Some formatting problems were also corrected. (Jari Aalto)

New Documentation

The perlpragma manpage documents how to write one's own lexicalpragmas in pure Perl (something that is possible starting with 5.9.4).

The new perlglossary manpage is a glossary of terms used in the Perldocumentation, technical and otherwise, kindly provided by O'Reilly Media,Inc.

The perlreguts manpage, courtesy of Yves Orton, describes internals of thePerl regular expression engine.

The perlreapi manpage describes the interface to the perl interpreterused to write pluggable regular expression engines (by Ævar ArnfjörðBjarmason).

The perlunitut manpage is an tutorial for programming with Unicode andstring encodings in Perl, courtesy of Juerd Waalboer.

A new manual page, perlunifaq (the Perl Unicode FAQ), has been added(Juerd Waalboer).

The perlcommunity manpage gives a description of the Perl communityon the Internet and in real life. (Edgar "Trizor" Bering)

The CORE manual page documents the CORE:: namespace. (Tels)

The long-existing feature of /(?{...})/ regexps setting $_ and pos()is now documented.

Performance Enhancements

In-place sorting

Sorting arrays in place (@a = sort @a) is now optimized to avoidmaking a temporary copy of the array.

Likewise, reverse sort ... is now optimized to sort in reverse,avoiding the generation of a temporary intermediate list.

Lexical array access

Access to elements of lexical arrays via a numeric constant between 0 and255 is now faster. (This used to be only the case for global arrays.)

XS-assisted SWASHGET

Some pure-perl code that perl was using to retrieve Unicode properties andtransliteration mappings has been reimplemented in XS.

Constant subroutines

The interpreter internals now support a far more memory efficient form ofinlineable constants. Storing a reference to a constant value in a symboltable is equivalent to a full typeglob referencing a constant subroutine,but using about 400 bytes less memory. This proxy constant subroutine isautomatically upgraded to a real typeglob with subroutine if necessary.The approach taken is analogous to the existing space optimisation forsubroutine stub declarations, which are stored as plain scalars in placeof the full typeglob.

Several of the core modules have been converted to use this feature fortheir system dependent constants - as a result use POSIX; now takes about200K less memory.

PERL_DONT_CREATE_GVSV

The new compilation flag PERL_DONT_CREATE_GVSV, introduced as an optionin perl 5.8.8, is turned on by default in perl 5.9.3. It prevents perlfrom creating an empty scalar with every new typeglob. See perl589deltafor details.

Weak references are cheaper

Weak reference creation is now O(1) rather than O(n), courtesy ofNicholas Clark. Weak reference deletion remains O(n), but if deletion onlyhappens at program exit, it may be skipped completely.

sort() enhancements

Salvador Fandiño provided improvements to reduce the memory usage of sortand to speed up some cases.

Memory optimisations

Several internal data structures (typeglobs, GVs, CVs, formats) have beenrestructured to use less memory. (Nicholas Clark)

UTF-8 cache optimisation

The UTF-8 caching code is now more efficient, and used more often.(Nicholas Clark)

Sloppy stat on Windows

On Windows, perl's stat() function normally opens the file to determinethe link count and update attributes that may have been changed throughhard links. Setting ${^WIN32_SLOPPY_STAT} to a true value speeds upstat() by not performing this operation. (Jan Dubois)

Regular expressions optimisations

  • Engine de-recursivised

    The regular expression engine is no longer recursive, meaning thatpatterns that used to overflow the stack will either die with usefulexplanations, or run to completion, which, since they were able to blowthe stack before, will likely take a very long time to happen. If you wereexperiencing the occasional stack overflow (or segfault) and upgrade todiscover that now perl apparently hangs instead, look for a degenerateregex. (Dave Mitchell)

  • Single char char-classes treated as literals

    Classes of a single character are now treated the same as if the characterhad been used as a literal, meaning that code that uses char-classes as anescaping mechanism will see a speedup. (Yves Orton)

  • Trie optimisation of literal string alternations

    Alternations, where possible, are optimised into more efficient matchingstructures. String literal alternations are merged into a trie and arematched simultaneously. This means that instead of O(N) time for matchingN alternations at a given point, the new code performs in O(1) time.A new special variable, ${^RE_TRIE_MAXBUF}, has been added to fine-tunethis optimization. (Yves Orton)

    Note: Much code exists that works around perl's historic poorperformance on alternations. Often the tricks used to do so will disablethe new optimisations. Hopefully the utility modules used for this purposewill be educated about these new optimisations.

  • Aho-Corasick start-point optimisation

    When a pattern starts with a trie-able alternation and there aren'tbetter optimisations available, the regex engine will use Aho-Corasickmatching to find the start point. (Yves Orton)

Installation and Configuration Improvements

Configuration improvements

  • -Dusesitecustomize

    Run-time customization of @INC can be enabled by passing the-Dusesitecustomize flag to Configure. When enabled, this will make perlrun $sitelibexp/sitecustomize.pl before anything else. This script canthen be set up to add additional entries to @INC.

  • Relocatable installations

    There is now Configure support for creating a relocatable perl tree. Ifyou Configure with -Duserelocatableinc, then the paths in @INC (andeverything else in %Config) can be optionally located via the path of theperl executable.

    That means that, if the string ".../" is found at the start of anypath, it's substituted with the directory of $^X. So, the relocation canbe configured on a per-directory basis, although the default with-Duserelocatableinc is that everything is relocated. The initialinstall is done to the original configured prefix.

  • strlcat() and strlcpy()

    The configuration process now detects whether strlcat() and strlcpy() areavailable. When they are not available, perl's own version is used (fromRuss Allbery's public domain implementation). Various places in the perlinterpreter now use them. (Steve Peters)

  • d_pseudofork and d_printf_format_null

    A new configuration variable, available as $Config{d_pseudofork} inthe Config module, has been added, to distinguish real fork() supportfrom fake pseudofork used on Windows platforms.

    A new configuration variable, d_printf_format_null, has been added, to see if printf-like formats are allowed to be NULL.

  • Configure help

    Configure -h has been extended with the most commonly used options.

Compilation improvements

  • Parallel build

    Parallel makes should work properly now, although there may still be problemsif make test is instructed to run in parallel.

  • Borland's compilers support

    Building with Borland's compilers on Win32 should work more smoothly. Inparticular Steve Hay has worked to side step many warnings emitted by theircompilers and at least one C compiler internal error.

  • Static build on Windows

    Perl extensions on Windows now can be statically built into the Perl DLL.

    Also, it's now possible to build a perl-static.exe that doesn't dependon the Perl DLL on Win32. See the Win32 makefiles for details.(Vadim Konovalov)

  • ppport.h files

    All ppport.h files in the XS modules bundled with perl are nowautogenerated at build time. (Marcus Holland-Moritz)

  • C++ compatibility

    Efforts have been made to make perl and the core XS modules compilablewith various C++ compilers (although the situation is not perfect withsome of the compilers on some of the platforms tested.)

  • Support for Microsoft 64-bit compiler

    Support for building perl with Microsoft's 64-bit compiler has beenimproved. (ActiveState)

  • Visual C++

    Perl can now be compiled with Microsoft Visual C++ 2005 (and 2008 Beta 2).

  • Win32 builds

    All win32 builds (MS-Win, WinCE) have been merged and cleaned up.

Installation improvements

  • Module auxiliary files

    README files and changelogs for CPAN modules bundled with perl are nolonger installed.

New Or Improved Platforms

Perl has been reported to work on Symbian OS. See perlsymbian for moreinformation.

Many improvements have been made towards making Perl work correctly onz/OS.

Perl has been reported to work on DragonFlyBSD and MidnightBSD.

Perl has also been reported to work on NexentaOS( http://www.gnusolaris.org/ ).

The VMS port has been improved. See perlvms.

Support for Cray XT4 Catamount/Qk has been added. Seehints/catamount.sh in the source code distribution for moreinformation.

Vendor patches have been merged for RedHat and Gentoo.

DynaLoader::dl_unload_file() now works on Windows.

Selected Bug Fixes

  • strictures in regexp-eval blocks

    strict wasn't in effect in regexp-eval blocks (/(?{...})/).

  • Calling CORE::require()

    CORE::require() and CORE::do() were always parsed as require() and do()when they were overridden. This is now fixed.

  • Subscripts of slices

    You can now use a non-arrowed form for chained subscripts after a listslice, like in:

    1. ({foo => "bar"})[0]{foo}

    This used to be a syntax error; a -> was required.

  • no warnings 'category' works correctly with -w

    Previously when running with warnings enabled globally via -w, selectivedisabling of specific warning categories would actually turn off all warnings.This is now fixed; now no warnings 'io'; will only turn off warnings in theio class. Previously it would erroneously turn off all warnings.

  • threads improvements

    Several memory leaks in ithreads were closed. Also, ithreads were madeless memory-intensive.

    threads is now a dual-life module, also available on CPAN. It has beenexpanded in many ways. A kill() method is available for thread signalling.One can get thread status, or the list of running or joinable threads.

    A new threads->exit() method is used to exit from the application(this is the default for the main thread) or from the current thread only(this is the default for all other threads). On the other hand, the exit()built-in now always causes the whole application to terminate. (JerryD. Hedden)

  • chr() and negative values

    chr() on a negative value now gives \x{FFFD}, the Unicode replacementcharacter, unless when the bytes pragma is in effect, where the loweight bits of the value are used.

  • PERL5SHELL and tainting

    On Windows, the PERL5SHELL environment variable is now checked fortaintedness. (Rafael Garcia-Suarez)

  • Using *FILE{IO}

    stat() and -X filetests now treat *FILE{IO} filehandles like *FILEfilehandles. (Steve Peters)

  • Overloading and reblessing

    Overloading now works when references are reblessed into another class.Internally, this has been implemented by moving the flag for "overloading"from the reference to the referent, which logically is where it shouldalways have been. (Nicholas Clark)

  • Overloading and UTF-8

    A few bugs related to UTF-8 handling with objects that havestringification overloaded have been fixed. (Nicholas Clark)

  • eval memory leaks fixed

    Traditionally, eval 'syntax error' has leaked badly. Many (but not all)of these leaks have now been eliminated or reduced. (Dave Mitchell)

  • Random device on Windows

    In previous versions, perl would read the file /dev/urandom if itexisted when seeding its random number generator. That file is unlikelyto exist on Windows, and if it did would probably not contain appropriatedata, so perl no longer tries to read it on Windows. (Alex Davies)

  • PERLIO_DEBUG

    The PERLIO_DEBUG environment variable no longer has any effect forsetuid scripts and for scripts run with -T.

    Moreover, with a thread-enabled perl, using PERLIO_DEBUG could lead toan internal buffer overflow. This has been fixed.

  • PerlIO::scalar and read-only scalars

    PerlIO::scalar will now prevent writing to read-only scalars. Moreover,seek() is now supported with PerlIO::scalar-based filehandles, theunderlying string being zero-filled as needed. (Rafael, Jarkko Hietaniemi)

  • study() and UTF-8

    study() never worked for UTF-8 strings, but could lead to false results.It's now a no-op on UTF-8 data. (Yves Orton)

  • Critical signals

    The signals SIGILL, SIGBUS and SIGSEGV are now always delivered in an"unsafe" manner (contrary to other signals, that are deferred until theperl interpreter reaches a reasonably stable state; seeDeferred Signals (Safe Signals) in perlipc). (Rafael)

  • @INC-hook fix

    When a module or a file is loaded through an @INC-hook, and when this hookhas set a filename entry in %INC, __FILE__ is now set for this moduleaccordingly to the contents of that %INC entry. (Rafael)

  • -t switch fix

    The -w and -t switches can now be used together without messingup which categories of warnings are activated. (Rafael)

  • Duping UTF-8 filehandles

    Duping a filehandle which has the :utf8 PerlIO layer set will nowproperly carry that layer on the duped filehandle. (Rafael)

  • Localisation of hash elements

    Localizing a hash element whose key was given as a variable didn't workcorrectly if the variable was changed while the local() was in effect (asin local $h{$x}; ++$x). (Bo Lindbergh)

New or Changed Diagnostics

  • Use of uninitialized value

    Perl will now try to tell you the name of the variable (if any) that wasundefined.

  • Deprecated use of my() in false conditional

    A new deprecation warning, Deprecated use of my() in false conditional,has been added, to warn against the use of the dubious and deprecatedconstruct

    1. my $x if 0;

    See perldiag. Use state variables instead.

  • !=~ should be !~

    A new warning, !=~ should be !~, is emitted to prevent this misspellingof the non-matching operator.

  • Newline in left-justified string

    The warning Newline in left-justified string has been removed.

  • Too late for "-T" option

    The error Too late for "-T" option has been reformulated to be moredescriptive.

  • "%s" variable %s masks earlier declaration

    This warning is now emitted in more consistent cases; in short, when oneof the declarations involved is a my variable:

    1. my $x; my $x;# warns
    2. my $x; our $x;# warns
    3. our $x; my $x;# warns

    On the other hand, the following:

    1. our $x; our $x;

    now gives a "our" variable %s redeclared warning.

  • readdir()/closedir()/etc. attempted on invalid dirhandle

    These new warnings are now emitted when a dirhandle is used but iseither closed or not really a dirhandle.

  • Opening dirhandle/filehandle %s also as a file/directory

    Two deprecation warnings have been added: (Rafael)

    1. Opening dirhandle %s also as a file
    2. Opening filehandle %s also as a directory
  • Use of -P is deprecated

    Perl's command-line switch -P is now deprecated.

  • v-string in use/require is non-portable

    Perl will warn you against potential backwards compatibility problems withthe use VERSION syntax.

  • perl -V

    perl -V has several improvements, making it more useable from shellscripts to get the value of configuration variables. See perlrun fordetails.

Changed Internals

In general, the source code of perl has been refactored, tidied up,and optimized in many places. Also, memory management and allocationhas been improved in several points.

When compiling the perl core with gcc, as many gcc warning flags areturned on as is possible on the platform. (This quest for cleanlinessdoesn't extend to XS code because we cannot guarantee the tidiness ofcode we didn't write.) Similar strictness flags have been added ortightened for various other C compilers.

Reordering of SVt_* constants

The relative ordering of constants that define the various types of SVhave changed; in particular, SVt_PVGV has been moved before SVt_PVLV,SVt_PVAV, SVt_PVHV and SVt_PVCV. This is unlikely to make anydifference unless you have code that explicitly makes assumptions about thatordering. (The inheritance hierarchy of B::* objects has been changedto reflect this.)

Elimination of SVt_PVBM

Related to this, the internal type SVt_PVBM has been removed. Thisdedicated type of SV was used by the index operator and parts of theregexp engine to facilitate fast Boyer-Moore matches. Its use internally hasbeen replaced by SVs of type SVt_PVGV.

New type SVt_BIND

A new type SVt_BIND has been added, in readiness for the project toimplement Perl 6 on 5. There deliberately is no implementation yet, andthey cannot yet be created or destroyed.

Removal of CPP symbols

The C preprocessor symbols PERL_PM_APIVERSION andPERL_XS_APIVERSION, which were supposed to give the version number ofthe oldest perl binary-compatible (resp. source-compatible) with thepresent one, were not used, and sometimes had misleading values. They havebeen removed.

Less space is used by ops

The BASEOP structure now uses less space. The op_seq field has beenremoved and replaced by a single bit bit-field op_opt. op_type is now 9bits long. (Consequently, the B::OP class doesn't provide an seqmethod anymore.)

New parser

perl's parser is now generated by bison (it used to be generated bybyacc.) As a result, it seems to be a bit more robust.

Also, Dave Mitchell improved the lexer debugging output under -DT.

Use of const

Andy Lester supplied many improvements to determine which functionparameters and local variables could actually be declared const to the Ccompiler. Steve Peters provided new *_set macros and reworked the core touse these rather than assigning to macros in LVALUE context.

Mathoms

A new file, mathoms.c, has been added. It contains functions that areno longer used in the perl core, but that remain available for binary orsource compatibility reasons. However, those functions will not becompiled in if you add -DNO_MATHOMS in the compiler flags.

AvFLAGS has been removed

The AvFLAGS macro has been removed.

av_* changes

The av_*() functions, used to manipulate arrays, no longer accept nullAV* parameters.

$^H and %^H

The implementation of the special variables $^H and %^H has changed, toallow implementing lexical pragmas in pure Perl.

B:: modules inheritance changed

The inheritance hierarchy of B:: modules has changed; B::NV nowinherits from B::SV (it used to inherit from B::IV).

Anonymous hash and array constructors

The anonymous hash and array constructors now take 1 op in the optreeinstead of 3, now that pp_anonhash and pp_anonlist return a reference toan hash/array when the op is flagged with OPf_SPECIAL. (Nicholas Clark)

Known Problems

There's still a remaining problem in the implementation of the lexical$_: it doesn't work inside /(?{...})/ blocks. (See the TODO test int/op/mydef.t.)

Stacked filetest operators won't work when the filetest pragma is ineffect, because they rely on the stat() buffer _ being populated, andfiletest bypasses stat().

UTF-8 problems

The handling of Unicode still is unclean in several places, where it'sdependent on whether a string is internally flagged as UTF-8. This willbe made more consistent in perl 5.12, but that won't be possible withouta certain amount of backwards incompatibility.

Platform Specific Problems

When compiled with g++ and thread support on Linux, it's reported that the$! stops working correctly. This is related to the fact that the glibcprovides two strerror_r(3) implementation, and perl selects the wrongone.

Reporting Bugs

If you find what you think is a bug, you might check the articlesrecently posted to the comp.lang.perl.misc newsgroup and the perlbug database at http://rt.perl.org/rt3/ . There may also beinformation at http://www.perl.org/ , the Perl Home Page.

If you believe you have an unreported bug, please run the perlbugprogram included with your release. Be sure to trim your bug downto a tiny but sufficient test case. Your bug report, along with theoutput of perl -V, will be sent off to [email protected] to beanalysed by the Perl porting team.

SEE ALSO

The Changes file and the perl590delta to perl595delta man pages forexhaustive details on what changed.

The INSTALL file for how to build Perl.

The README file for general stuff.

The Artistic and Copying files for copyright information.

Page index
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) What is new for perl v5.10.1What is new for perl v5.8.9 (Berikutnya)