allows you to refer to special variables (like $RS ) as though they were in awk; see the perlvar manpage for details.
ifs and whiles.
/pat/ /pat/ unparsable, since the third slash
would be interpreted as a division operator--the tokener is in fact
slightly context sensitive for operators like ``/'', ``?'', and ``>''.
And in fact, ``.'' itself can be the beginning of a number.)
The following variables work differently:
if's and while's.
elsif rather than else if.
break and
continue
keywords from C become in
Perl
last
and
next
, respectively.
Unlike in C, these do NOT work within a
do { } while
construct.
ARGV must be capitalized.
$ARGV
[0] is C's argv[1], and argv[0]
ends up in
$0
.
..., rather than comma.
BEGIN blocks, which
execute at compile time).
='' when you need ``=~'';
these two constructs are quite different:
@ now always interpolates an array in double-quotish strings. Some programs
may now need to use backslash to protect any @ that shouldn't interpolate.
In Perl 4, that set the signal handler; in Perl 5, it actually calls the function! You may use the -w switch to find such places.
_ are no longer forced into package main, except
for
$_
itself (and @_, etc.).
s'$lhs'$rhs' now does no interpolation on either side. It used to
interpolate $lhs but not $rhs.
Because if that were to work, then this couldn't:
Otherwise
would be erroneously parsed as
On the other hand,
now works as a C programmer would expect.
m//g now attaches its state to the searched string rather than the
regular expression.
$ or @.
while/if BLOCK BLOCK syntax is no longer supported.
** operator now binds more tightly than unary minus.
It was documented to work this way before, but didn't.
$#
array lower now discards array elements.