Just a guess: Did you tried to set $SIG{__WARN__} to an empty sub { } or to undef at the very beginning of the eval to catch the warnings?

Update: I thought now about a tiny test for this:
perl -e '$a=10; eval { $SIG{__WARN__} = sub {  }; $a->isa('foo')}; print "Eval: ", $@, "\n"'
or
perl -e '$a=10; eval { $SIG{__WARN__} = undef; $a->isa('foo')}; print "Eval: ", $@, "\n"'

Both have the warning still in $@. I can't say much about a tied STDERR but it looks pretty much that this isn't working. One another idea I had was to localise the STDERR typeglob inside eval:

perl -e '$a=10; eval { local *STDERR; print STDERR "Test\n"; $a->isa('foo'); }; print $@;'

While this still sets the warning inside $@ the message to STDERR isn't printed. It's worth a try.


In reply to Re: Prevent my STDERR logging in evals... by mscharrer
in thread Prevent my STDERR logging in evals... by suaveant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.