perlquestion
Ovid
<p>I need to profile some code, but I've discovered that the program behaves differently when using [cpan://Devel::DProf]. Below is my test case and the ouput. I've duplicated this bug with Perl 5.8.0 on two computers, both running RH Linux. I'll send this off to P5P if it's not a known issue, but in the meantime, have I missed something?</p>
<readmore>
<code> #!/usr/bin/perl
use strict;
parse(1,0);
sub parse {
while (defined(my $number = shift)) {
print "Number: $number\n";
&parse if $number;
}
}</code>
<p>And the results:</p>
<code> $ perl test.pl
Number: 1
Number: 0
$ perl -d:DProf test.pl
Number: 1
Number: 0
Number: 0</code>
<p>By changing the recursive call to parse() to the following:</p>
<code> parse(@_) if $number;</code>
<p>I get the following results:</p>
<code> $ perl test.pl
Number: 1
Number: 0
Number: 0
$ perl -d:DProf test.pl
Number: 1
Number: 0
Number: 0</code>
<p>However, that looks like <em>both</em> versions are wrong because somehow the final zero is getting read twice by [shift]. What am I missing?</p>
<p>Cheers,<br />
<a href="/index.pl?node=Ovid&lastnode_id=1072">Ovid</a></p>
<p><small>New address of <a href="http://users.easystreet.com/ovid/cgi_course/">my CGI Course</a>.</small></p>