Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/src/cmd/perl/Changes5.000

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


-------------
Version 5.000
-------------

New things
----------
    The -w switch is much more informative.

    References.  See t/op/ref.t for examples.  All entities in Perl 5 are
    reference counted so that it knows when each item should be destroyed.

    Objects.  See t/op/ref.t for examples.

    => is now a synonym for comma.  This is useful as documentation for
    arguments that come in pairs, such as initializers for associative arrays,
    or named arguments to a subroutine.

    All functions have been turned into list operators or unary operators,
    meaning the parens are optional.  Even subroutines may be called as
    list operators if they've already been declared.

    More embeddible.  See main.c and embed_h.sh.  Multiple interpreters
    in the same process are supported (though not with interleaved
    execution yet).

    The interpreter is now flattened out.  Compare Perl 4's eval.c with
    the perl 5's pp.c.  Compare Perl 4's 900 line interpreter loop in cmd.c
    with Perl 5's 1 line interpreter loop in run.c.  Eventually we'll make
    everything non-blocking so we can interface nicely with a scheduler.

    eval is now treated more like a subroutine call.  Among other things,
    this means you can return from it.

    Format value lists may be spread over multiple lines by enclosing in
    a do {} block.

    You may now define BEGIN and END subroutines for each package.  The BEGIN
    subroutine executes the moment it's parsed.  The END subroutine executes
    just before exiting.

    Flags on the #! line are interpreted even if the script wasn't
    executed directly.  (And even if the script was located by "perl -x"!)

    The ?: operator is now legal as an lvalue.

    List context now propagates to the right side of && and ||, as well
    as the 2nd and 3rd arguments to ?:.

    The "defined" function can now take a general expression.

    Lexical scoping available via "my".  eval can see the current lexical
    variables.

    The preferred package delimiter is now :: rather than '.

    tie/untie are now preferred to dbmopen/dbmclose.  Multiple DBM
    implementations are allowed in the same executable, so you can
    write scripts to interchange data among different formats.

    New "and" and "or" operators work just like && and || but with
    a precedence lower than comma, so they work better with list operators.

    New functions include: abs(), chr(), uc(), ucfirst(), lc(), lcfirst(),
    chomp(), glob()

    require with a number checks to see that the version of Perl that is
    currently running is at least that number.

    Dynamic loading of external modules is now supported.

    There is a new quote form qw//, which is equivalent to split(' ', q//).

    Assignment of a reference to a glob value now just replaces the
    single element of the glob corresponding to the reference type:
	*foo = \$bar, *foo = \&bletch;

    Filehandle methods are now supported:
	output_autoflush STDOUT 1;

    There is now an "English" module that provides human readable translations
    for cryptic variable names.

    Autoload stubs can now call the replacement subroutine with goto &realsub.

    Subroutines can be defined lazily in any package by declaring an AUTOLOAD
    routine, which will be called if a non-existent subroutine is called in
    that package.

    Several previously added features have been subsumed under the new
    keywords "use" and "no".  Saying "use Module LIST" is short for
	BEGIN { require Module; import Module LIST; }
    The "no" keyword is identical except that it calls "unimport" instead.
    The earlier pragma mechanism now uses this mechanism, and two new
    modules have been added to the library to implement "use integer"
    and variations of "use strict vars, refs, subs".

    Variables may now be interpolated literally into a pattern by prefixing
    them with \Q, which works just like \U, but backwhacks non-alphanumerics
    instead.  There is also a corresponding quotemeta function.

    Any quantifier in a regular expression may now be followed by a ? to
    indicate that the pattern is supposed to match as little as possible.

    Pattern matches may now be followed by an m or s modifier to explicitly
    request multiline or singleline semantics.  An s modifier makes . match
    newline.

    Patterns may now contain \A to match only at the beginning of the string,
    and \Z to match only at the end.  These differ from ^ and $ in that
    they ignore multiline semantics.  In addition, \G matches where the
    last interation of m//g or s///g left off.

    Non-backreference-producing parens of various sorts may now be
    indicated by placing a ? directly after the opening parenthesis,
    followed by a character that indicates the purpose of the parens.
    An :, for instance, indicates simple grouping.  (?:a|b|c) will
    match any of a, b or c without producing a backreference.  It does
    "eat" the input.  There are also assertions which do not eat the
    input but do lookahead for you.  (?=stuff) indicates that the next
    thing must be "stuff".  (?!nonsense) indicates that the next thing
    must not be "nonsense".

    The negation operator now treats non-numeric strings specially.
    A -"text" is turned into "-text", so that -bareword is the same
    as "-bareword".  If the string already begins with a + or -, it
    is flipped to the other sign.

Incompatibilities
-----------------
    @ now always interpolates an array in double-quotish strings.  Some programs
    may now need to use backslash to protect any @ that shouldn't interpolate.

    Ordinary variables starting with underscore are no longer forced into
    package main.

    s'$lhs'$rhs' now does no interpolation on either side.  It used to
    interplolate $lhs but not $rhs.

    The second and third arguments of splice are now evaluated in scalar
    context (like the book says) rather than list context.

    Saying "shift @foo + 20" is now a semantic error because of precedence.

    "open FOO || die" is now incorrect.  You need parens around the filehandle.

    The elements of argument lists for formats are now evaluated in list
    context.  This means you can interpolate list values now.

    You can't do a goto into a block that is optimized away.  Darn.

    It is no longer syntactically legal to use whitespace as the name
    of a variable, or as a delimiter for any kind of quote construct.

    Some error messages will be different.

    The caller function now returns a false value in a scalar context if there
    is no caller.  This lets library files determine if they're being required.

    m//g now attaches its state to the searched string rather than the
    regular expression.

    "reverse" is no longer allowed as the name of a sort subroutine.

    taintperl is no longer a separate executable.  There is now a -T
    switch to turn on tainting when it isn't turned on automatically.

    Symbols starting with _ are no longer forced into package main, except
    for $_ itself (and @_, etc.).

    Double-quoted strings may no longer end with an unescaped $ or @.

    Negative array subscripts now count from the end of the array.

    The comma operator in a scalar context is now guaranteed to give a
    scalar context to its arguments.

    The ** operator now binds more tightly than unary minus.

    Setting $#array lower now discards array elements so that destructors
    work reasonably.

    delete is not guaranteed to return the old value for tied arrays,
    since this capability may be onerous for some modules to implement.

    Attempts to set $1 through $9 now result in a run-time error.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].