in reply to Re^3: BEGIN and compile-time
in thread BEGIN and compile-time

It is more appropriate to test $@.

Oh, I disagree. There are too many cases where $@ doesn't survive. It is more fool-proof (and one of my "best practices") to check the return value of eval "....; 1" to determine whether or not eval failed (and then to use $@ to report what the error was, though $@ might no long contain this information).

- tye        

Replies are listed 'Best First'.
Re^5: BEGIN and compile-time ($@)
by imp (Priest) on Nov 10, 2006 at 19:57 UTC
    That's a good point.
    Could you provide an example of where a failed eval "use Foo" does not result in $@ being populated?

      It usually involves a "broken" object DESTROY method, usually one that uses eval but forgets to local( $@ ).

      - tye