in reply to Prototypes required even after mocking a sub
If you set the prototype of your mock sub before replacing the original one, that should get rid of the warning, try commenting out the set_prototype call in the following and you should get the "Prototype mismatch" warning back:
use warnings; use strict; use Scalar::Util qw/set_prototype/; sub foo ($$$) { print "foo(@_)\n" } foo(1,2,3); # prints "foo(1 2 3)" { my $name = "foo"; my $sub = sub { print "bar(@_)\n" }; set_prototype(\&$sub,prototype($name)); #use Devel::Peek; Dump($sub); no strict 'refs'; no warnings 'redefine'; *$name = $sub; } foo(4,5,6); # prints "bar(4 5 6)"
By the way, in the code you showed, you're disabling strict 'refs' for a fairly large block of code.
|
|---|