http://qs1969.pair.com?node_id=496788


in reply to eval with semicolon

For historical reasons, to make it easier for perl to parse your Perl, eval is classified as an expression.

As an expression it needs to be seperated from the next expression so that perl doesn't get confused.

The advantage of having it as an expression is that it can have a return value. (In this case, the result of the evaled code)

By adding a ; to the end of an expression it turns it into a statement.

The ; is not added automatically because this would make the job of parsing harder for perl. Different languages have different approaches to dealing with this, but as a member of the C family - Perl requires certain statements to be delimited explictly with a ;.

-Andrew.


Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com