http://www.perlmonks.org?node_id=996317


in reply to how to make close() fail

$ perl -MErrno=EIO -E' BEGIN { *CORE::GLOBAL::close = sub { if (caller eq "other::package") { $! = EIO; return 0; } return CORE::close($_[0]); }; } package other::package; close(STDOUT) or die $!; ' Input/output error at -e line 14.