per Larry's idea, parse 1.2.3 as v1.2.3; C<require 5.6.0> and
[p5sagit/p5-mst-13.2.git] / pod / perldelta.pod
index 6fc7d8f..4fd3ce4 100644 (file)
@@ -57,6 +57,45 @@ cases remains unchanged:
 
 See L<perldata>.
 
+=head2 Perl's version numbering has changed
+
+Beginning with Perl version 5.6, the version number convention has been
+changed to a "dotted integer" scheme that is more commonly found in open
+source projects.
+
+Maintenance versions of v5.6.0 will be released as v5.6.1, v5.6.2 etc.
+The next development series following v5.6 will be numbered v5.7.x,
+beginning with v5.7.0, and the next major production release following
+v5.6 will be v5.8.
+
+The English module now sets $PERL_VERSION to $^V (a string value) rather
+than C<$]> (a numeric value).  (This is a potential incompatibility.
+Send us a report via perlbug if you are affected by this.)
+
+The v1.2.3 syntax is also now legal in Perl.
+See L<Support for strings represented as a vector of ordinals> for more on that.
+
+To cope with the new versioning system's use of at least three significant
+digits for each version component, the method used for incrementing the
+subversion number has also changed slightly.  We assume that versions older
+than v5.6 have been incrementing the subversion component in multiples of
+10.  Versions after v5.6.0 will increment them by 1.  Thus, using the new
+notation, 5.005_03 is the same as v5.5.30, and the first maintenance
+version following v5.6.0 will be v5.6.1, which amounts to a floating point
+value of 5.006_001).
+
+=item Literals of the form C<1.2.3> parse differently
+
+Previously, numeric literals with more than one dot in them were
+interpreted as a floating point number concatenated with one or more
+numbers.  Such "numbers" are now parsed as strings composed of the
+specified ordinals.
+
+For example, C<print 97.98.99> used to output C<97.9899> in earlier
+versions, but now prints C<abc>.
+
+See L<Support for strings represented as a vector of ordinals> below.
+
 =item Possibly changed pseudo-random number generator
 
 In 5.005_0x and earlier, perl's rand() function used the C library
@@ -81,13 +120,15 @@ Using the C<undef> operator on a readonly value (such as $1) has
 the same effect as assigning C<undef> to the readonly value--it
 throws an exception.
 
-=item Close-on-exec bit may be set on pipe() handles
+=item Close-on-exec bit may be set on pipe and socket handles
 
 On systems that support a close-on-exec flag on filehandles, the
-flag will be set for any handles created by pipe(), if that is
-warranted by the value of $^F that may be in effect.  Earlier
-versions neglected to set the flag for handles created with
-pipe().  See L<perlfunc/pipe> and L<perlvar/$^F>.
+flag will be set for any handles created by pipe(), socketpair(),
+socket(), and accept(), if that is warranted by the value of $^F
+that may be in effect.  Earlier versions neglected to set the flag
+for handles created with these operators.  See L<perlfunc/pipe>,
+L<perlfunc/socketpair>, L<perlfunc/socket>, L<perlfunc/accept>,
+and L<perlvar/$^F>.
 
 =item Writing C<"$$1"> to mean C<"${$}1"> is unsupported
 
@@ -270,12 +311,27 @@ For the full list of public API functions, see L<perlapi>.
 
 =head1 Installation and Configuration Improvements
 
+=head2 -Dusethreads means something different
+
+WARNING: Support for threads continues to be an experimental feature.
+Interfaces and implementation are subject to sudden and drastic changes.
+
+The -Dusethreads flag now enables the experimental interpreter-based thread
+support by default.  To get the flavor of experimental threads that was in
+5.005 instead, you need to ask for -Duse5005threads.
+
+As of v5.5.640, interpreter-threads support is still lacking a way to
+create new threads from Perl (i.e., C<use Thread;> will not work with
+interpreter threads).  C<use Thread;> continues to be available when you
+ask for -Duse5005threads, bugs and all.
+
 =head2 New Configure flags
 
 The following new flags may be enabled on the Configure command line
 by running Configure with C<-Dflag>.
 
     usemultiplicity
+    use5005threads
 
     uselongdouble
     usemorebits
@@ -284,11 +340,13 @@ by running Configure with C<-Dflag>.
 =head2 -Dusethreads and -Duse64bits now more daring
 
 The Configure options enabling the use of threads and the use of
-64-bitness are now more daring in the sense that they no more have
-an explicit list of operating systems of known threads/64-bit
+64-bitness are now more daring in the sense that they no more have an
+explicit list of operating systems of known threads/64-bit
 capabilities.  In other words: if your operating system has the
-necessary APIs, you should be able just to go ahead and use them.
-See also L<"64-bit support">.
+necessary APIs and datatypes, you should be able just to go ahead and
+use them, for threads by Configure -Dusethreads, and for 64 bits
+either explicitly by Configure -Duse64bits or implicitly if your
+system has 64 bit wide datatypes.  See also L<"64-bit support">.
 
 =head2 Long Doubles
 
@@ -340,10 +398,11 @@ building and installing from source, the defaults should be fine.
 =head2 Unicode and UTF-8 support
 
 Perl can optionally use UTF-8 as its internal representation for character
-strings.  The C<utf8> pragma enables this support in the current lexical
-scope.  See L<utf8> for more information.
+strings.  The C<utf8> and C<bytes> pragmas are used to control this support
+in the current lexical scope.  See L<perlunicode>, L<utf8> and L<bytes> for
+more information.
 
-=head2 Interpreter threads
+=head2 Interpreter cloning, threads, and concurrency
 
 WARNING: This is an experimental feature in a pre-alpha state.  Use
 at your own risk.
@@ -367,24 +426,24 @@ interpreters, little or no locking will be needed (unless parts of
 the symbol table are explicitly shared).  This is obviously intended
 to be an easy-to-use replacement for the existing threads support.
 
-Support for cloning interpreters must currently be manually enabled
-by defining the cpp macro USE_ITHREADS on non-Windows platforms.
-(See win32/Makefile for how to enable it on Windows.)  The resulting
-perl executable will be functionally identical to one that was built
-without USE_ITHREADS, but the perl_clone() API call will only be
-available in the former.
+Support for cloning interpreters and interpreter concurrency can be
+enabled using the -Dusethreads Configure option (see win32/Makefile for
+how to enable it on Windows.)  The resulting perl executable will be
+functionally identical to one that was built with -Dmultiplicity, but
+the perl_clone() API call will only be available in the former.
 
-USE_ITHREADS enables Perl source code changes that provide a clear
-separation between the op tree and the data it operates with.  The
-former is considered immutable, and can therefore be shared between
-an interpreter and all of its clones, while the latter is considered
-local to each interpreter, and is therefore copied for each clone.
+-Dusethreads enables, the cpp macros USE_ITHREADS by default, which enables
+Perl source code changes that provide a clear separation between the op tree
+and the data it operates with.  The former is considered immutable, and can
+therefore be shared between an interpreter and all of its clones, while the
+latter is considered local to each interpreter, and is therefore copied for
+each clone.
 
 Note that building Perl with the -Dusemultiplicity Configure option
 is adequate if you wish to run multiple B<independent> interpreters
-concurrently in different threads.  USE_ITHREADS only needs to be
-enabled if you wish to obtain access to perl_clone() and cloned
-interpreters.
+concurrently in different threads.  -Dusethreads only provides the
+additional functionality of the perl_clone() API call and other
+support for running B<cloned> interpreters concurrently.
 
 [XXX TODO - the Compiler backends may be broken when USE_ITHREADS is
 enabled.]
@@ -401,23 +460,87 @@ WARNING: This is an experimental feature.
 
 change#4081
 [TODO - Ilya Zakharevich <ilya@math.ohio-state.edu>,
-Tuomas Lukka <lukka@fas.harvard.edu>)]
+Tuomas Lukka <lukka@iki.fi>)]
 
 =head2 "our" declarations
 
 An "our" declaration introduces a value that can be best understood
 as a lexically scoped symbolic alias to a global variable in the
-current package.  This is mostly useful as an alternative to the
-C<vars> pragma, but also provides the opportunity to introduce
-typing and other attributes for such variables.  See L<perlfunc/our>.
+package that was current where the variable was declared.  This is
+mostly useful as an alternative to the C<vars> pragma, but also provides
+the opportunity to introduce typing and other attributes for such
+variables.  See L<perlfunc/our>.
+
+=head2 Support for strings represented as a vector of ordinals
+
+Literals of the form C<v1.2.3.4> are now parsed as a string composed of
+of characters with the specified ordinals.  This is an alternative, more
+readable way to construct (possibly unicode) strings instead of
+interpolating characters, as in C<"\x{1}\x{2}\x{3}\x{4}">.  The leading
+C<v> may be omitted if there are more than two ordinals, so C<1.2.3> is
+parsed the same as C<v1.2.3>.
+
+Strings written in this form are also useful to represent version "numbers".
+It is easy to compare such version "numbers" (which are really just plain
+strings) using any of the usual string comparison operators C<eq>, C<ne>,
+C<lt>, C<gt>, etc., or perform bitwise string operations on them using C<|>,
+C<&>, etc.
+
+In conjunction with the new C<$^V> magic variable (which contains
+the perl version as a string), such literals can be used as a readable way
+to check if you're running a particular version of Perl:
+
+    # this will parse in older versions of Perl also
+    if ($^V and $^V gt v5.5.640) {
+        # new features supported
+    }
+
+C<require> and C<use> also have some special magic to support such literals.
+They will be interpreted as a version rather than as a module name:
+
+    require v5.6.0;            # croak if $^V lt v5.6.0
+    use v5.6.0;                        # same, but croaks at compile-time
+
+Alternatively, the C<v> may be omitted if there is more than one dot:
+
+    require 5.6.0;
+    use 5.6.0;
+
+Also, C<sprintf> and C<printf> support the Perl-specific format flag C<%v>
+to print ordinals of characters in arbitrary strings:
+
+    printf "v%vd", $^V;                # prints current version, such as "v5.5.650"
+    printf "%*vX", ":", $addr; # formats IPv6 address
+    printf "%*vb", " ", $bits; # displays bitstring
+
+See L<perlop/"Strings of Character"> for additional information.
 
 =head2 Weak references
 
 WARNING: This is an experimental feature.
 
-change#3385, also need perlguts documentation
+In previous versions of Perl, you couldn't cache objects so as
+to allow them to be deleted if the last reference from outside 
+the cache is deleted.  The reference in the cache would hold a
+reference count on the object and the objects would never be
+destroyed.
+
+Another familiar problem is with circular references.  When an
+object references itself, its reference count would never go
+down to zero, and it would not get destroyed until the program
+is about to exit.
+
+Weak references solve this by allowing you to "weaken" any
+reference, that is, make it not count towards the reference count.
+When the last non-weak reference to an object is deleted, the object
+is destroyed and all the weak references to the object are
+automatically undef-ed.
 
-[TODO - Tuomas Lukka <lukka@fas.harvard.edu>]
+To use this feature, you need the WeakRef package from CPAN, which
+contains additional documentation.
+
+change#3385, also need perlguts documentation
+[TODO - Tuomas Lukka <lukka@iki.fi>]
 
 =head2 File globbing implemented internally
 
@@ -440,10 +563,10 @@ C<oct()>:
 
 Perl now allows the arrow to be omitted in many constructs
 involving subroutine calls through references.  For example,
-C<$foo[10]->('foo')> may now be written C<$foo[10]('foo')>.
+C<$foo[10]-E<gt>('foo')> may now be written C<$foo[10]('foo')>.
 This is rather similar to how the arrow may be omitted from
-C<$foo[10]->{'foo'}>.  Note however, that the arrow is still
-required for C<foo(10)->('bar')>.
+C<$foo[10]-E<gt>{'foo'}>.  Note however, that the arrow is still
+required for C<foo(10)-E<gt>('bar')>.
 
 =head2 exists() is supported on subroutine names
 
@@ -457,15 +580,17 @@ The exists() and delete() builtins now work on simple arrays as well.
 The behavior is similar to that on hash elements.
 
 exists() can be used to check whether an array element has been
-initialized without autovivifying it.  If the array is tied, the
-EXISTS() method in the corresponding tied package will be invoked.
+initialized.  This avoids autovivifying array elements that don't exist.
+If the array is tied, the EXISTS() method in the corresponding tied
+package will be invoked.
 
 delete() may be used to remove an element from the array and return
 it.  The array element at that position returns to its unintialized
 state, so that testing for the same element with exists() will return
 false.  If the element happens to be the one at the end, the size of
-the array also shrinks by one.  If the array is tied, the DELETE() method
-in the corresponding tied package will be invoked.
+the array also shrinks up to the highest element that tests true for
+exists(), or 0 if none such is found.  If the array is tied, the DELETE() 
+method in the corresponding tied package will be invoked.
 
 See L<perlfunc/exists> and L<perlfunc/delete> for examples.
 
@@ -475,7 +600,7 @@ The length argument of C<syswrite()> has become optional.
 
 =head2 File and directory handles can be autovivified
 
-Similar to how constructs such as C<$x->[0]> autovivify a reference,
+Similar to how constructs such as C<$x-E<gt>[0]> autovivify a reference,
 handle constructors (open(), opendir(), pipe(), socketpair(), sysopen(),
 socket(), and accept()) now autovivify a file or directory handle
 if the handle passed to them is an uninitialized scalar variable.  This
@@ -541,8 +666,11 @@ Note that unless you have the case (a) you will have to configure
 and compile Perl using the -Duse64bits Configure flag.
 
 Unfortunately bit arithmetics (&, |, ^, ~, <<, >>) for numbers are not
-64-bit clean, they are explictly forced to be 32-bit.  Bit arithmetics
-for bit vectors (created by vec()) are not limited in their width.
+64-bit clean, they are explictly forced to be 32-bit because of
+tangled backward compatibility issues.  This limitation is subject to
+change.  Bit arithmetics for bit vector scalars (created by vec()) are
+not limited in their width, you can use the & | ^ ~ operators on such
+scalars.
 
 Last but not least: note that due to Perl's habit of always using
 floating point numbers the quads are still not true integers.
@@ -689,14 +817,24 @@ acquire special meaning in any future version of Perl.
 Formerly, if you wanted to mark a subroutine as being a method call or
 as requiring an automatic lock() when it is entered, you had to declare
 that with a C<use attrs> pragma in the body of the subroutine.
-That can now be accomplished with a declaration syntax, like this:
+That can now be accomplished with declaration syntax, like this:
 
     sub mymethod : locked method ;
     ...
-    sub mymethod : locked :method {
+    sub mymethod : locked method {
        ...
     }
 
+    sub othermethod :locked :method ;
+    ...
+    sub othermethod :locked :method {
+       ...
+    }
+
+
+(Note how only the first C<:> is mandatory, and whitespace surrounding
+the C<:> is optional.)
+
 F<AutoSplit.pm> and F<SelfLoader.pm> have been updated to keep the attributes
 with the stubs they provide.  See L<attributes>.
 
@@ -740,6 +878,15 @@ BEGIN blocks are executed under such conditions, this variable
 enables perl code to determine whether actions that make sense
 only during normal running are warranted.  See L<perlvar>.
 
+=head2 New variable $^V contains Perl version in v5.6.0 format
+
+C<$^V> contains the Perl version number as a string composed of
+characters whose ordinals match the version numbers, so that it may
+be used in string comparisons.
+
+See C<Support for strings represented as a vector of ordinals> for an
+example.
+
 =head2 Optional Y2K warnings
 
 If Perl is built with the cpp macro C<PERL_Y2KWARN> defined,
@@ -747,7 +894,7 @@ it emits optional warnings when concatenating the number 19
 with another number.
 
 This behavior must be specifically enabled when running Configure.
-See L<INSTALL> and L<README.Y2K>.
+See F<INSTALL> and F<README.Y2K>.
 
 =head1 Significant bug fixes
 
@@ -854,7 +1001,7 @@ array element in that slot.
 =head2 Pseudo-hashes work better
 
 Dereferencing some types of reference values in a pseudo-hash,
-such as C<$ph->{foo}[1]>, was accidentally disallowed.  This has
+such as C<$ph-E<gt>{foo}[1]>, was accidentally disallowed.  This has
 been corrected.
 
 When applied to a pseudo-hash element, exists() now reports whether
@@ -1102,6 +1249,14 @@ detected at the end of the line containing the __END__ or __DATA__
 token; if not, the DATA filehandle will be left open in binary mode.
 Earlier versions always opened the DATA filehandle in text mode.
 
+The glob() operator is implemented via the L<File::Glob> extension,
+which supports glob syntax of the C shell.  This increases the flexibility
+of the glob() operator, but there may be compatibility issues for
+programs that relied on the older globbing syntax.  If you want to
+preserve compatibility with the older syntax, you might want to put
+a C<use File::DosGlob;> in your program.  For details and compatibility
+information, see L<File::Glob>.
+
 [TODO - GSAR]
 
 =head1 New tests
@@ -1265,6 +1420,11 @@ For other details, see L<Benchmark>.
 The Devel::Peek module provides access to the internal representation
 of Perl variables and data.  It is a data debugging tool for the XS programmer.
 
+=item English
+
+$PERL_VERSION now stands for C<$^V> (a string value) rather than for C<$]>
+(a numeric value).
+
 =item ExtUtils::MakeMaker
 
 change#4135, also needs docs in module pod
@@ -1277,8 +1437,11 @@ large file (more than 4GB) access Note that the O_LARGEFILE is
 automatically/transparently added to sysopen() flags if large file
 support has been configured), Free/Net/OpenBSD locking behaviour flags
 F_FLOCK, F_POSIX, Linux F_SHLCK, and O_ACCMODE: the combined mask of
-O_RDONLY, O_WRONLY, and O_RDWR.  Also SEEK_SET, SEEK_CUR, and SEEK_END
-added for one-stop shopping of the seek/sysseek constants.
+O_RDONLY, O_WRONLY, and O_RDWR.  The seek()/sysseek() constants
+SEEK_SET, SEEK_CUR, and SEEK_END are available via the C<:seek> tag.
+The chmod()/stat() S_IF* constants and S_IS* functions are available
+via the C<:mode> tag.
+
 
 =item File::Compare
 
@@ -1426,9 +1589,66 @@ act as mutators (accessor $z->Re(), mutator $z->Re(3)).
 A little bit of radial trigonometry (cylindrical and spherical),
 radial coordinate conversions, and the great circle distance were added.
 
-=item Pod::Parser
+=item Pod::Parser, Pod::InputObjects
+
+Pod::Parser is a base class for parsing and selecting sections of
+pod documentation from an input stream.  This module takes care of
+identifying pod paragraphs and commands in the input and hands off the
+parsed paragraphs and commands to user-defined methods which are free
+to interpret or translate them as they see fit.
+
+Pod::InputObjects defines some input objects needed by Pod::Parser, and
+for advanced users of Pod::Parser that need more about a command besides
+its name and text.
+
+As of release 5.6 of Perl, Pod::Parser is now the officially sanctioned
+"base parser code" recommended for use by all pod2xxx translators.
+Pod::Text (pod2text) and Pod::Man (pod2man) have already been converted
+to use Pod::Parser and efforts to convert Pod::HTML (pod2html) are already
+underway.  For any questions or comments about pod parsing and translating
+issues and utilities, please use the pod-people@perl.org mailing list.
+
+For further information, please see L<Pod::Parser> and L<Pod::InputObjects>.
+
+=item Pod::Checker, podchecker
+
+This utility checks pod files for correct syntax, according to
+L<perlpod>.  Obvious errors are flagged as such, while warnings are
+printed for mistakes that can be handled gracefully.  The checklist is
+not complete yet.  See L<Pod::Checker>.
+
+=item Pod::ParseUtils, Pod::Find
+
+These modules provide a set of gizmos that are useful mainly for pod
+translators.  L<Pod::Find|Pod::Find> traverses directory structures and
+returns found pod files, along with their canonical names (like
+C<File::Spec::Unix>).  L<Pod::ParseUtils|Pod::ParseUtils> contains
+B<Pod::List> (useful for storing pod list information), B<Pod::Hyperlink>
+(for parsing the contents of C<LE<gt>E<lt>> sequences) and B<Pod::Cache>
+(for caching information about pod files, e.g. link nodes).
+
+=item Pod::Select, podselect
+
+Pod::Select is a subclass of Pod::Parser which provides a function
+named "podselect()" to filter out user-specified sections of raw pod
+documentation from an input stream. podselect is a script that provides
+access to Pod::Select from other scripts to be used as a filter.
+See L<Pod::Select>.
+
+=item Pod::Usage, pod2usage
+
+Pod::Usage provides the function "pod2usage()" to print usage messages for
+a Perl script based on its embedded pod documentation.  The pod2usage()
+function is generally useful to all script authors since it lets them
+write and maintain a single source (the pods) for documentation, thus
+removing the need to create and maintain redundant usage message text
+consisting of information already in the pods.
 
-[TODO - Brad Appleton <bradapp@enteract.com>]
+There is also a pod2usage script which can be used from other kinds of
+scripts to print usage messages from pods (even for non-Perl scripts
+with pods embedded in comments).
+
+For details and examples, please see L<Pod::Usage>.
 
 =item Pod::Text and Pod::Man
 
@@ -1445,6 +1665,16 @@ A bug that may have caused data loss when more than one disk block
 happens to be read from the database in a single FETCH() has been
 fixed.
 
+=item Sys::Syslog
+
+Sys::Syslog now uses XSUBs to access facilities from syslog.h so it
+no longer requires syslog.ph to exist. 
+
+=item Sys::Hostname
+
+Sys::Hostname now uses XSUBs to call the C library's gethostname() or
+uname() if they exist.
+
 =item Time::Local
 
 The timelocal() and timegm() functions used to silently return bogus
@@ -1498,10 +1728,6 @@ syntax.  See L<perlsub/"Subroutine Attributes"> and L<attributes>.
 
 C<use utf8> to enable UTF-8 and Unicode support.
 
-C<use caller 'encoding'> allows modules to inherit pragmatic attributes
-from the caller's context.  C<encoding> is currently the only supported
-attribute.
-
 Lexical warnings pragma, C<use warnings;>, to control optional warnings.
 See L<perllexwarn>.
 
@@ -1568,6 +1794,10 @@ A tutorial that introduces the essentials of references.
 
 A tutorial on managing class data for object modules.
 
+=item perlunicode.pod
+
+An introduction to Unicode support features in Perl.
+
 =back
 
 =head1 New or Changed Diagnostics
@@ -1716,6 +1946,22 @@ most likely an unexpected right brace '}'.
 malloc()ed in the first place. Mandatory, but can be disabled by
 setting environment variable C<PERL_BADFREE> to 1.
 
+=item Bareword found in conditional
+
+(W) The compiler found a bareword where it expected a conditional,
+which often indicates that an || or && was parsed as part of the
+last argument of the previous construct, for example:
+
+    open FOO || die;
+
+It may also indicate a misspelled constant that has been interpreted
+as a bareword:
+
+    use constant TYPO => 1;
+    if (TYOP) { print "foo" }
+
+The C<strict> pragma is useful in avoiding such errors.
+
 =item Binary number > 0b11111111111111111111111111111111 non-portable
 
 (W) The binary number you specified is larger than 2**32-1
@@ -2033,7 +2279,7 @@ when you meant
 
     my ($foo, $bar) = @_;
 
-Remember that "my", "our" and "local" bind closer than comma.
+Remember that "my", "our", and "local" bind tighter than comma.
 
 =item Possible Y2K bug: %s
 
@@ -2096,8 +2342,8 @@ L<perlvms>) so that the environ array isn't the target of the change to
 =item Unknown open() mode '%s'
 
 (F) The second argument of 3-argument open() is not among the list
-of valid modes: C<L<lt>>, C<L<gt>>, C<E<gt>E<gt>>, C<+L<lt>>,
-C<+L<gt>>, C<+E<gt>E<gt>>, C<-|>, C<|->.
+of valid modes: C<E<lt>>, C<E<gt>>, C<E<gt>E<gt>>, C<+E<lt>>,
+C<+E<gt>>, C<+E<gt>E<gt>>, C<-|>, C<|E<45>>.
 
 =item Unknown process %x sent message to prime_env_iter: %s
 
@@ -2175,6 +2421,14 @@ appear in %ENV.  This may be a benign occurrence, as some software packages
 might directly modify logical name tables and introduce nonstandard names,
 or it may indicate that a logical name table has been corrupted.
 
+=item Probable precedence problem on %s
+
+(W) The compiler found a bareword where it expected a conditional,
+which often indicates that an || or && was parsed as part of the
+last argument of the previous construct, for example:
+
+    open FOO || die;
+
 =item regexp too big
 
 (F) The current implementation of regular expressions uses shorts as