- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

4.11.6 Differences from Perl 6

The Perl 5 smart match and given/when constructs are not absolutely identical to their Perl 6 analogues. The most visible difference is that, in Perl 5, parentheses are required around the argument to given() and when() (except when this last one is used as a statement modifier). Parentheses in Perl 6 are always optional in a control construct such as if(), while(), or when(); they can't be made optional in Perl 5 without a great deal of potential confusion, because Perl 5 would parse the expression

given $foo {

as though the argument to given were an element of the hash %foo, interpreting the braces as hash-element syntax.

The table of smart matches is not identical to that proposed by the Perl 6 specification, mainly due to the differences between Perl 6's and Perl 5's data models.

In Perl 6, when() will always do an implicit smart match with its argument, whilst it is convenient in Perl 5 to suppress this implicit smart match in certain situations, as documented above. (The difference is largely because Perl 5 does not, even internally, have a boolean type.)

ISBN 9781906966027Perl Language Reference ManualSee the print edition