in reply to Debugging DBD::Chart
Note that $total is now never used, so there's no longer any reason to be calculating it above.my @sorted = sort { $events{$b}{'count'} <=> $events{$a}{'count'} } keys %events; if (@sorted > $max_wedges) { map { $events{'other'}{'count'} += $_ } @sorted[$max_wedges..$#sorted]; @sorted[$max_wedges..$#sorted] = ('other'); } return [map { {$_ => $events{$_}{'count'}}; } @sorted];
This uses map heavily, which is sometimes a bit odd to get used to, but I find it leads me to write stuff that I can look at later and easily read. YMMV.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
2Re: Debugging DBD::Chart
by jeffa (Bishop) on Feb 21, 2004 at 16:53 UTC |