[Phoenix-pm] perl eval and the No Execute chips
Scott Walters
scott at
Wed Sep 13 10:42:39 PDT 2006
Carp is your friend! Get a stack trace. Especially helpful if the
error happened while deeply nested in subroutine calls...
#!/usr/bin/perl
# use MIME::Lite;
use Carp 'confess';
eval q{
die fladermous /* if keyboard */
};
confess $@ if $@;
On 0, "David A. Sinck" <phx-pm-list at grueslayer.com> wrote:
>
>
> \_ SMTP quoth Brock on 9/12/2006 22:32 as having spake thusly:
> \_
> \_ But that's a bit of a side track. Really, let's expand the question to
> \_ this -- How does "eval" work?
>
> Better yet, when you get a death from captured by an eval eg:
>
> ---------------
> #!/usr/bin/perl
>
> use MIME::Lite;
>
> eval q{
> die fladermous /* if keyboard */
> };
>
> print $@;
> --------------
> Bareword found where operator expected at (eval 10) line 2, near "* if
> keyboard"
> (Missing operator before keyboard?)
> Search pattern not terminated at (eval 10) line 2.
> --------------
>
> How do you know in your code which eval \d+ it is? Sure, if it's a
> simple script you can count as it's inc'd from one. But I want to
> know which eval is mine in more robust settings (hence the use in the
> exapmle).
>
> The only way I've solved this before was adding a faulty mini eval
> immediately prior to the eval I cared about and and parsing $@ from
> that and guessing that it should be a single increment to get to the
> eval I cared about.
>
> David
> _______________________________________________
> Phoenix-pm mailing list
> Phoenix-pm at pm.org
> http://mail.pm.org/mailman/listinfo/phoenix-pm
More information about the Phoenix-pm
mailing list