Subject: | Patch for Profiler.pm |
Hi there, please find attached a patch for Profiler.pm, which is part of Parse-Nibbler-1.10.tar.gz. This is my first submitted patch, and I made it with diff -ru <original> <fixed>. I hope this is cool.
It fixes an issue in Profiler.pm where the code being instrumented under Profiler forces subroutines to return scalars. This patch changes Profiler so that profiled subroutines can return arrays.
Dist : Parse-Nibbler-1.10.tar.gz
PERL: 5.6
OS : Linux RedHat 7.1
Code that shows the bug
use Profiler;
my @results = &foo(45);
print "Results are ",Dumper(\@results),"\n";
sub foo
{ my @stuff = (1,2,3,4);
print "Wantarray is ",wantarray,"\n";
return @stuff;
}
Should give "Wantarray 1", and does if "use Profiler;" is removed.
Kind regards and thankyou for this excellent resource
Craig Burton
Daniel Burton
The Online Assessment Company theoac.com
--- Profiler.pm Fri Feb 22 16:59:50 2002
+++ Profiler_new.pm Fri Feb 22 16:59:07 2002
@@ -278,14 +278,16 @@
{
__pre_code ( $name );
- my $ret_val;
- eval{ $ret_val = &$coderef; };
+ my @ret_val;
+ eval{ @ret_val = &$coderef; };
my $eval_error = $@;
__post_code ( $name );
die ($eval_error) if ($eval_error);
- return $ret_val;
+ return @ret_val if wantarray;
+ return $ret_val[0];
+
};
my $install_string = '*'.$name.' = \&$instrumented_ref; ' ;