Subject: | [PATCH] Documentation extended for subroutines with parameters |
Hi,
it took me a while to find out how to override subroutine with
parameters. I guess attached paragraph can be useful for other
beginners too.
Regards,
David
--- Sub-Override-0.08.orig/lib/Sub/Override.pm 2005-09-21
20:08:01.000000000 +0200
+++ Sub-Override-0.08/lib/Sub/Override.pm 2011-04-22
21:35:15.484375000 +0200
@@ -177,6 +177,10 @@
->replace('Some::sub2', sub { 'new data2' })
->replace('Some::sub3', sub { 'new data3' });
+New subroutine must be declared with same number of parameters as the
original one:
+
+ $override->replace('Some::sub_with_params', sub ($$) { ($_[0], $_
[1]) });
+
A subroutine may be replaced as many times as desired. This is most
useful
when testing how code behaves with multiple conditions.
Subject: | pod_subroutines_with_params.patch |
diff -ur Sub-Override-0.08.orig//lib/Sub/Override.pm Sub-Override-0.08//lib/Sub/Override.pm
--- Sub-Override-0.08.orig//lib/Sub/Override.pm 2005-09-21 20:08:01.000000000 +0200
+++ Sub-Override-0.08//lib/Sub/Override.pm 2011-04-22 21:35:15.484375000 +0200
@@ -177,6 +177,10 @@
->replace('Some::sub2', sub { 'new data2' })
->replace('Some::sub3', sub { 'new data3' });
+New subroutine must be declared with same number of parameters as the original one:
+
+ $override->replace('Some::sub_with_params', sub ($$) { ($_[0], $_[1]) });
+
A subroutine may be replaced as many times as desired. This is most useful
when testing how code behaves with multiple conditions.