Skip Menu |

This queue is for tickets about the DBIx-Profile CPAN distribution.

Report information
The Basics
Id: 738
Status: new
Priority: 0/
Queue: DBIx-Profile

People
Owner: Nobody in particular
Requestors: ivan-cpan-rt [...] 420.am
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: sprintf method to return the profiling data instead [patch]
A small patch to add a `sprintf' method to return the profiling information instead of print it.
oops here is the patch itself
diff -u DBIx-Profile-1.0/Profile.pm DBIx-Profile-1.0ivan1/Profile.pm --- DBIx-Profile-1.0/Profile.pm Tue Aug 29 14:41:21 2000 +++ DBIx-Profile-1.0ivan1/Profile.pm Sat Mar 17 10:52:51 2001 @@ -225,9 +225,16 @@ # JEFF - The printing and the print code is kinda (er... very) ugly! # +#like printProfile, except returns the results instead of printing them. +sub sprintProfile { + my $self = shift; + $self->printProfile({'sprint'=>1}); +} + sub printProfile { my $self = shift; + my $args = shift; my %result; my $total = 0; no integer; @@ -292,13 +299,18 @@ $result{$total} = $text; } # each query + my $results; foreach my $qry (sort stripsort keys %result) { - if ($DBIx::Profile::DBIXFILE eq "" ) { + if ( $args->{'sprint'} ) { + $results .= $result{$qry} . "\n"; + } elsif ($DBIx::Profile::DBIXFILE eq "" ) { warn $result{$qry} . "\n"; } else { print $DBIx::Profile::DBIXFILEHANDLE $result{$qry} . "\n"; } } + + return $results if $args->{'sprint'}; } sub stripsort {