Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: eval with semicolon

by tomazos (Deacon)
on Oct 02, 2005 at 21:19 UTC ( #496788=note: print w/replies, xml ) Need Help??

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 Tomazos  |  |

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://496788]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2023-12-06 16:40 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (30 votes). Check out past polls.