in reply to how to make close() fail

Create a "filehandle" using IO::Callback. This allows you to run a callback coderef on file accesses and when the file is closed. The callback can simulate system errors.

In particular, see examples 6 and 7 in the pod.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'