2009/12/15 Shlomi Fish <shlo...@iglu.org.il>:
> On Tuesday 15 Dec 2009 14:25:28 Xiao Lan (小兰) wrote:
>> On Tue, Dec 15, 2009 at 7:50 PM, Xiao Lan (小兰) <practicalp...@gmail.com>
> wrote:
>> > I did have tried that, but this will get a runtime error.
>>
>> Sorry this is exactly a compile-time error.
>>
>> # cat except.pl
>>
>> eval { $x=12/0 };
>> print "0 div error" if $@;
>>
>> # perl -c except.pl
>> Illegal division by zero at except.pl line 2.
>>
>> So, can't we capture it at runtime when meeting such error?
>>
>
> No, you cannot capture compile-time errors at runtime. You'll need to make
> sure your code compiles before you run it. Note that you can capture such
> errors if you do perldoc -f require, perldoc -f do (for a filename), string
> eval "", etc. at run-time, in which case perl 5 invokes its compiler to
> compile some code at run-time.

How can "Illegal division by zero" be a compile-time error? It seems
clear to me that it's a run-time error, which the optimizer has
(wrongly) decided to raise at compile-time.

Phil

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to