Perl FAQ 1.5: Will perl5 break my perl4 scripts?
Perl FAQ 1.5
Will perl5 break my perl4 scripts?
In general, no. However, certain bad old practices have become highly
frowned upon. The following are the most important of the known
incompatibilities between perl4 and perl5. See
perltrap(1)
for more
details.
- @ ALWAYS interpolates in double quoted strings. Non-array
@'s must be escaped:
Mail("foo@bar.com")
needs to be
Mail("foo\@bar.com");
The compiler catches this.
- open FILE || die needs to be open(FILE) || die. The compiler
forgives you for this, but won't stop complaining until you fix it.
- Barewords are no longer (necessarily) strings: they will actually
call the function (if it existed when that code was compiled)
instead of returning a string of that value. Check your
signal handlers. The use strict subs pragma (see
strict(3pm)
)
will help you with this.
- shift @x + 20 needs to be shift(@x) + 20 because of precedence,
and likewise $y = scalar keys %foo + 30 needs to be instead
$y = scalar keys(%foo) + 30.
- The internal symbol table is called %{PACKAGE::} for any given
package. It used to be %{_PACKAGE}.
- You may no longer (attempt to) write to read-only variables, like $1,
or assign to a substr() past the end of a string.
- Various deprecated practices elicit warning messages.
- The package delimiter has been changed from ' to ::. Use of ' is
deprecated, but still works. Use of :: may break scripts if you
aren't careful (especially if you are working with colon delimited
data files, like /etc/passwd).
Other resources at this site: