eyepopslikeamosquito has asked for the wisdom of the Perl Monks concerning the following question:
I want to test open and print failures. This crude trick overrides open with a failing one:
However, this attempt does not override print 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";
I suspect I just need to get the right prototype for print. How do I override the print function to make it fail?BEGIN { *CORE::GLOBAL::print = sub (*;@) { return undef }; } open(my $fh, '>', 'f.tmp') or die "error: open"; print $fh "hello\n" or die "error: print";
|
---|
Back to
Seekers of Perl Wisdom