Skip Menu |

This queue is for tickets about the Sub-Override CPAN distribution.

Report information
The Basics
Id: 67704
Status: resolved
Priority: 0/
Queue: Sub-Override

People
Owner: Nobody in particular
Requestors: david.skyba [...] centrum.cz
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.08
Fixed in: (no value)



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.
This is resolved as of 0.09, currently on its way to the CPAN. Sorry it took so long and thanks for the patch! Cheers, Ovid