Obviously, more info is always helpful in dissecting code, but here are a few general comments:
- As evidenced by the call &$action($$trdstmt->fetchrow_hashref());, $action is a code ref, though I'd need to see more code to determine is it is an anonymous sub. I'd also have to see more code to know what it does.
- Based on the structure, I'm guessing that $trade in the while-loop contains your database return. A simple way to examine its contents should be to use Data::Dumper, a la:
while(my $trade = $trdstmt->fetchrow_hashref()) {
print Dumper $trade;
&$action(%$trade);
$count++;
}
after adding use Data::Dumper; to your code.
- I am guessing based on syntax that $self is a DBI database handle. Assuming this is the case, I would suggest instrumenting to test for success on your database calls. Perhaps something like:
$trdstmt->bind_param(1,$self->{'startdate'}) or die "Bind failed:
+$DBI::errstr";
$trdstmt->bind_param(2,$self->{'enddate'}) or die "Bind failed: $D
+BI::errstr";
$trdstmt->execute() or die "Execute: $DBI::errstr";
- For a reasonable review of Perl approaches to tackle this task, read Basic debugging checklist.
Update: Note the bug caught by bluescreen below.