in reply to Getting stderr from a test::simple

Why do you expect this to print a warning? If the open call in mycheck fails, you return an anonymous subroutine. Test::Simple checks if this equals 0 (which it does not), so the test fails. At no point is the subroutine you return actually called, hence no warning.

Replies are listed 'Best First'.
Re^2: Getting stderr from a test::simple
by neilwatson (Priest) on Jul 01, 2014 at 18:10 UTC

      Acceptable, probably, but if you merely want to print a warning in addition to making the test fail, I'd say do is your best choice:

      open (FH, '>', '/tmp/x/logfile') or do { warn "Cannot open file [$!]"; return 1; };

      There may well be more idiomatic ways of doing (no pun intended) this that I'm not aware of. My monastic brothers will (probably) be happy to chime in!