I suppose the reason it's more efficient is that it compiles it at actual compile time. The only use I know of eval{} is catching dies...
On 10/23/06, Paul Cochrane <[EMAIL PROTECTED]> wrote:
> > This patch adds a test for DOS line endings in text files in the > > Parrot distribution. > > > > Comments welcome, > > Hi Paul, > > could you add a check for SVN::Client and skip the test when there is no > SVN::Client? Bernhard, No worries :-) Please see attached patch. I noticed something odd when I was testing this patch. When I used the following code (adapted directly from perlcritic.t ) BEGIN { eval { use SVN::Client; }; if ($@) { plan skip_all => 'SVN::Client not installed'; } } and tested that the test couldn't find SVN::Client and hence would skip the tests, I got a compile-time error that the module wasn't in @INC, yet when I change the eval statement to: eval "use SVN::Client"; it works (by printing just the message: "SVN::Client not installed"), and yet Programming Perl says that the latter C<eval> is just a less efficient form of the former. Any ideas what's going on here? I then tested perlcritic.t and found that it gives an @INC compile time error too when it can't find Test::Perl::Critic, and I can supply a patch for that if you want. The reason I ask is that even though I have a solution, I don't know *why* it works, and I'd like to, but can't seem to find any reason for the difference between the C<eval> forms. Many thanks in advance! Paul files affected: MANIFEST t/codingstd/line_endings.t