| 1 | -------------
|
|---|
| 2 | Version 5.000
|
|---|
| 3 | -------------
|
|---|
| 4 |
|
|---|
| 5 | New things
|
|---|
| 6 | ----------
|
|---|
| 7 | The -w switch is much more informative.
|
|---|
| 8 |
|
|---|
| 9 | References. See t/op/ref.t for examples. All entities in Perl 5 are
|
|---|
| 10 | reference counted so that it knows when each item should be destroyed.
|
|---|
| 11 |
|
|---|
| 12 | Objects. See t/op/ref.t for examples.
|
|---|
| 13 |
|
|---|
| 14 | => is now a synonym for comma. This is useful as documentation for
|
|---|
| 15 | arguments that come in pairs, such as initializers for associative arrays,
|
|---|
| 16 | or named arguments to a subroutine.
|
|---|
| 17 |
|
|---|
| 18 | All functions have been turned into list operators or unary operators,
|
|---|
| 19 | meaning the parens are optional. Even subroutines may be called as
|
|---|
| 20 | list operators if they've already been declared.
|
|---|
| 21 |
|
|---|
| 22 | More embeddible. See main.c and embed_h.sh. Multiple interpreters
|
|---|
| 23 | in the same process are supported (though not with interleaved
|
|---|
| 24 | execution yet).
|
|---|
| 25 |
|
|---|
| 26 | The interpreter is now flattened out. Compare Perl 4's eval.c with
|
|---|
| 27 | the perl 5's pp.c. Compare Perl 4's 900 line interpreter loop in cmd.c
|
|---|
| 28 | with Perl 5's 1 line interpreter loop in run.c. Eventually we'll make
|
|---|
| 29 | everything non-blocking so we can interface nicely with a scheduler.
|
|---|
| 30 |
|
|---|
| 31 | eval is now treated more like a subroutine call. Among other things,
|
|---|
| 32 | this means you can return from it.
|
|---|
| 33 |
|
|---|
| 34 | Format value lists may be spread over multiple lines by enclosing in
|
|---|
| 35 | a do {} block.
|
|---|
| 36 |
|
|---|
| 37 | You may now define BEGIN and END subroutines for each package. The BEGIN
|
|---|
| 38 | subroutine executes the moment it's parsed. The END subroutine executes
|
|---|
| 39 | just before exiting.
|
|---|
| 40 |
|
|---|
| 41 | Flags on the #! line are interpreted even if the script wasn't
|
|---|
| 42 | executed directly. (And even if the script was located by "perl -x"!)
|
|---|
| 43 |
|
|---|
| 44 | The ?: operator is now legal as an lvalue.
|
|---|
| 45 |
|
|---|
| 46 | List context now propagates to the right side of && and ||, as well
|
|---|
| 47 | as the 2nd and 3rd arguments to ?:.
|
|---|
| 48 |
|
|---|
| 49 | The "defined" function can now take a general expression.
|
|---|
| 50 |
|
|---|
| 51 | Lexical scoping available via "my". eval can see the current lexical
|
|---|
| 52 | variables.
|
|---|
| 53 |
|
|---|
| 54 | The preferred package delimiter is now :: rather than '.
|
|---|
| 55 |
|
|---|
| 56 | tie/untie are now preferred to dbmopen/dbmclose. Multiple DBM
|
|---|
| 57 | implementations are allowed in the same executable, so you can
|
|---|
| 58 | write scripts to interchange data among different formats.
|
|---|
| 59 |
|
|---|
| 60 | New "and" and "or" operators work just like && and || but with
|
|---|
| 61 | a precedence lower than comma, so they work better with list operators.
|
|---|
| 62 |
|
|---|
| 63 | New functions include: abs(), chr(), uc(), ucfirst(), lc(), lcfirst(),
|
|---|
| 64 | chomp(), glob()
|
|---|
| 65 |
|
|---|
| 66 | require with a number checks to see that the version of Perl that is
|
|---|
| 67 | currently running is at least that number.
|
|---|
| 68 |
|
|---|
| 69 | Dynamic loading of external modules is now supported.
|
|---|
| 70 |
|
|---|
| 71 | There is a new quote form qw//, which is equivalent to split(' ', q//).
|
|---|
| 72 |
|
|---|
| 73 | Assignment of a reference to a glob value now just replaces the
|
|---|
| 74 | single element of the glob corresponding to the reference type:
|
|---|
| 75 | *foo = \$bar, *foo = \&bletch;
|
|---|
| 76 |
|
|---|
| 77 | Filehandle methods are now supported:
|
|---|
| 78 | output_autoflush STDOUT 1;
|
|---|
| 79 |
|
|---|
| 80 | There is now an "English" module that provides human readable translations
|
|---|
| 81 | for cryptic variable names.
|
|---|
| 82 |
|
|---|
| 83 | Autoload stubs can now call the replacement subroutine with goto &realsub.
|
|---|
| 84 |
|
|---|
| 85 | Subroutines can be defined lazily in any package by declaring an AUTOLOAD
|
|---|
| 86 | routine, which will be called if a non-existent subroutine is called in
|
|---|
| 87 | that package.
|
|---|
| 88 |
|
|---|
| 89 | Several previously added features have been subsumed under the new
|
|---|
| 90 | keywords "use" and "no". Saying "use Module LIST" is short for
|
|---|
| 91 | BEGIN { require Module; import Module LIST; }
|
|---|
| 92 | The "no" keyword is identical except that it calls "unimport" instead.
|
|---|
| 93 | The earlier pragma mechanism now uses this mechanism, and two new
|
|---|
| 94 | modules have been added to the library to implement "use integer"
|
|---|
| 95 | and variations of "use strict vars, refs, subs".
|
|---|
| 96 |
|
|---|
| 97 | Variables may now be interpolated literally into a pattern by prefixing
|
|---|
| 98 | them with \Q, which works just like \U, but backwhacks non-alphanumerics
|
|---|
| 99 | instead. There is also a corresponding quotemeta function.
|
|---|
| 100 |
|
|---|
| 101 | Any quantifier in a regular expression may now be followed by a ? to
|
|---|
| 102 | indicate that the pattern is supposed to match as little as possible.
|
|---|
| 103 |
|
|---|
| 104 | Pattern matches may now be followed by an m or s modifier to explicitly
|
|---|
| 105 | request multiline or singleline semantics. An s modifier makes . match
|
|---|
| 106 | newline.
|
|---|
| 107 |
|
|---|
| 108 | Patterns may now contain \A to match only at the beginning of the string,
|
|---|
| 109 | and \Z to match only at the end. These differ from ^ and $ in that
|
|---|
| 110 | they ignore multiline semantics. In addition, \G matches where the
|
|---|
| 111 | last interation of m//g or s///g left off.
|
|---|
| 112 |
|
|---|
| 113 | Non-backreference-producing parens of various sorts may now be
|
|---|
| 114 | indicated by placing a ? directly after the opening parenthesis,
|
|---|
| 115 | followed by a character that indicates the purpose of the parens.
|
|---|
| 116 | An :, for instance, indicates simple grouping. (?:a|b|c) will
|
|---|
| 117 | match any of a, b or c without producing a backreference. It does
|
|---|
| 118 | "eat" the input. There are also assertions which do not eat the
|
|---|
| 119 | input but do lookahead for you. (?=stuff) indicates that the next
|
|---|
| 120 | thing must be "stuff". (?!nonsense) indicates that the next thing
|
|---|
| 121 | must not be "nonsense".
|
|---|
| 122 |
|
|---|
| 123 | The negation operator now treats non-numeric strings specially.
|
|---|
| 124 | A -"text" is turned into "-text", so that -bareword is the same
|
|---|
| 125 | as "-bareword". If the string already begins with a + or -, it
|
|---|
| 126 | is flipped to the other sign.
|
|---|
| 127 |
|
|---|
| 128 | Incompatibilities
|
|---|
| 129 | -----------------
|
|---|
| 130 | @ now always interpolates an array in double-quotish strings. Some programs
|
|---|
| 131 | may now need to use backslash to protect any @ that shouldn't interpolate.
|
|---|
| 132 |
|
|---|
| 133 | Ordinary variables starting with underscore are no longer forced into
|
|---|
| 134 | package main.
|
|---|
| 135 |
|
|---|
| 136 | s'$lhs'$rhs' now does no interpolation on either side. It used to
|
|---|
| 137 | interplolate $lhs but not $rhs.
|
|---|
| 138 |
|
|---|
| 139 | The second and third arguments of splice are now evaluated in scalar
|
|---|
| 140 | context (like the book says) rather than list context.
|
|---|
| 141 |
|
|---|
| 142 | Saying "shift @foo + 20" is now a semantic error because of precedence.
|
|---|
| 143 |
|
|---|
| 144 | "open FOO || die" is now incorrect. You need parens around the filehandle.
|
|---|
| 145 |
|
|---|
| 146 | The elements of argument lists for formats are now evaluated in list
|
|---|
| 147 | context. This means you can interpolate list values now.
|
|---|
| 148 |
|
|---|
| 149 | You can't do a goto into a block that is optimized away. Darn.
|
|---|
| 150 |
|
|---|
| 151 | It is no longer syntactically legal to use whitespace as the name
|
|---|
| 152 | of a variable, or as a delimiter for any kind of quote construct.
|
|---|
| 153 |
|
|---|
| 154 | Some error messages will be different.
|
|---|
| 155 |
|
|---|
| 156 | The caller function now returns a false value in a scalar context if there
|
|---|
| 157 | is no caller. This lets library files determine if they're being required.
|
|---|
| 158 |
|
|---|
| 159 | m//g now attaches its state to the searched string rather than the
|
|---|
| 160 | regular expression.
|
|---|
| 161 |
|
|---|
| 162 | "reverse" is no longer allowed as the name of a sort subroutine.
|
|---|
| 163 |
|
|---|
| 164 | taintperl is no longer a separate executable. There is now a -T
|
|---|
| 165 | switch to turn on tainting when it isn't turned on automatically.
|
|---|
| 166 |
|
|---|
| 167 | Symbols starting with _ are no longer forced into package main, except
|
|---|
| 168 | for $_ itself (and @_, etc.).
|
|---|
| 169 |
|
|---|
| 170 | Double-quoted strings may no longer end with an unescaped $ or @.
|
|---|
| 171 |
|
|---|
| 172 | Negative array subscripts now count from the end of the array.
|
|---|
| 173 |
|
|---|
| 174 | The comma operator in a scalar context is now guaranteed to give a
|
|---|
| 175 | scalar context to its arguments.
|
|---|
| 176 |
|
|---|
| 177 | The ** operator now binds more tightly than unary minus.
|
|---|
| 178 |
|
|---|
| 179 | Setting $#array lower now discards array elements so that destructors
|
|---|
| 180 | work reasonably.
|
|---|
| 181 |
|
|---|
| 182 | delete is not guaranteed to return the old value for tied arrays,
|
|---|
| 183 | since this capability may be onerous for some modules to implement.
|
|---|
| 184 |
|
|---|
| 185 | Attempts to set $1 through $9 now result in a run-time error.
|
|---|