jackthehipster
jackthehipster

Reputation: 1018

Why is there a syntax error with this eval?

I'm just trying eval for the first time, and get a compilation error for the following piece of code:

my $dom;
eval {
    $dom = $PRSR->load_xml(location => $fullpathname, no_blanks => 1);
}

my $dtlDocType = getObjectType($dom); # <----- the error occurs here

It says "Global symbol $dtlDocType requires explicit package name". When I remove the eval and let the line setting $dom stay without a block, it works. Initializing $dom in the first line to anything doesn't make any difference.

What is the problem?

Upvotes: 0

Views: 529

Answers (1)

TLP
TLP

Reputation: 67900

eval { ... } needs a semi-colon after it.

Upvotes: 4

Related Questions