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