I have a perl script that reports the avg time of a application call and the total number of calls. This works fine, however I would like to trim the number of decimal places reported from 12 to like 3 and I don't know how.
Any suggestions? Here is what I use to get the avg time...
for $eRef ( @operationInfoArray ) {
$avgTime = $eRef->{TIME}/$eRef->{COUNT};
print "$eRef->{NAME} : $avgTime : $eRef->{COUNT}\n";
Result...........
GET_HIST : 193.529040881471 : 113719
OPEN_BATCH : 142.549565217391 : 575
CLOSE_BATCH : 164.506297229219 : 397
Thanks
Ikon
October 15, 2008, 5:41pm
2
$something = 123.123456789
$something = sprintf("%.3f", $something);
now something = 123.123
theninja:
I have a perl script that reports the avg time of a application call and the total number of calls. This works fine, however I would like to trim the number of decimal places reported from 12 to like 3 and I don't know how.
Any suggestions? Here is what I use to get the avg time...
for $eRef ( @operationInfoArray ) {
$avgTime = $eRef->{TIME}/$eRef->{COUNT};
print "$eRef->{NAME} : $avgTime : $eRef->{COUNT}\n";
Result...........
GET_HIST : 193.529040881471 : 113719
OPEN_BATCH : 142.549565217391 : 575
CLOSE_BATCH : 164.506297229219 : 397
Thanks
What actually your script will do? Is it calculate the average time taken for the execution of the script and number of times the script is called?
If so, i like to discuss regarding the script, find intresting and expecting one like that!