On Fri, 31 Mar 2006 16:33:56 +0200, [EMAIL PROTECTED] (Tomas Zerolo)
wrote:

>On Fri, Mar 31, 2006 at 05:41:32AM -0800, Steve Thames wrote:
>> Consider this:
>> 
>>      my %names = (Bob => 'Robert Brower');
>>      my $caption = 'Name: $names{Bob)';
>>      print  eval "qq|$caption|";
>[...]
>> Does anyone have any idea how to capture the syntax error in a case
>> like this?
>
>
>You mean something like...
>
>  my %names = (Bob => 'Robert Brower');
>  my $caption = 'Name: $names{Bob)';
>  print  eval "qq|$caption|";
>  die $@ if $@
>
>giving:
>
>  syntax error at (eval 1) line 1, near "Bob)"
>  Missing right curly or square bracket at (eval 1) line 1, within string
>
>HTH
>-- tomas

Exactly right.  Except $@ is empty in this construction--no error is
reported but the eval fails.

It has something to do with the way perl uses the setjmp and longjmp c
functions.  I was reading something about that.

I'm trying to trap the syntax error.

Reply via email to