I want to test open and print failures.
This crude trick overrides open with a failing one:
BEGIN {
*CORE::GLOBAL::open = sub (*;$$) { return undef };
}
open(my $fh, '>', 'f.tmp') or die "error: open";
print $fh "hello\n" or die "error: print";
However, this attempt does not override print with a failing one:
BEGIN {
*CORE::GLOBAL::print = sub (*;@) { return undef };
}
open(my $fh, '>', 'f.tmp') or die "error: open";
print $fh "hello\n" or die "error: print";
I suspect I just need to get the right prototype for print.
How do I override the print function to make it fail?