On Feb 24, 2004, at 3:17 AM, Rafael Garcia-Suarez wrote:

Randy W. Sims wrote:

I've CC'd p5p for enlightenment & simplified your code to the following:


my @code = (
   q('a poorly 'nested' string'),
   q('a poorly 'nested::nested' string'),
);

for (@code) {
   eval;
   print "Caught: $@" if $@;
}

Output is:

Caught: Bad name after nested' at (eval 1) line 1.

That's for the first one.
Remember that ' is a package separator; so perl, seeing nested', expects
an identifier (a name) to follow. Hence the error. See perldiag for
more info on it.


Bareword found where operator expected at (eval 2) line 1, near "'a
poorly 'nested::nested"
(Missing operator before nested::nested?)
String found where operator expected at (eval 2) line 1, near
"nested::nested' string'"
Caught: syntax error at (eval 2) line 1, near "'a poorly 'nested::nested"

Here, perl successfully parses the full identifier nested::nested.
What it doesn't understand is, why is there an identifier at this place ?
It was expecting an operator instead.

But since it's inside an eval() call, those messages should get stuck in $@ and NOT printed. As Randy has said, they would kill a normal program, if they were in the source. They are not warnings. eval() is correctly keeping the program running here, but incorrectly printing the messages that would have killed it, right?


James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to