On 02/24/04 04:17, 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.

Ok, I can just about get my mind around it. Just about...


If I give perl the program:

'a 'nested' string'

I get the first error above, which is a compile time error. No code is executed.

If I change it slightly (spaces around the bare word):

'a ' nested ' string'
    ^       ^

I get the second error above, also compile time errors. No code is executed.

The only thing missing from my understanding is why eval EXPR let's some errors through and catches some in [EMAIL PROTECTED] I know it is documented not to trap errors, I.e. you need to do something like $SIG{__WARN__}=sub{} to silence the output. What is the differentiator between the two cases?

Thanks,
Randy.

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