in reply to Re^3: Working out frequency statistics with perl
in thread Working out frequency statistics with perl
Which is obviously incorrect, but not sure what I need to change to get the results you got?open(READMAP, "$command |") || error_exit("Cannot run readmap, $!"); +#run the readmap command while(<READMAP>) { #loop through the output of the readmap command if (/StageTime/){ @fields = split/\s+/; + #Split the output by white space chop $fields[9]; + # Remove the period after the last digit $diskxStats[$i]{'filesize'}=$fields[2]; $diskxStats[$i]{'ftptime'}=$fields[5]; $diskxStats[$i]{'stagetime'}=$fields[9]; if ( $fields[5] != 0 ){ $diskxStats[$i]{'transferRate'} = $fields[2] / $fields[5]; } else{ $diskxStats[$i]{'transferRate'} = $fields[2]; } if ( $fields[9] != 0 ){ $diskxStats[$i]{'stagerate'} = $fields[2] / $fields[9]; } else{ $diskxStats[$i]{'stagerate'} = $fields[2]; } $i++; } } for $i (0 .. $#diskxStats ) { build_histogram ($bin_stage, $diskxStats[$i]{'stagetime'}); } sub build_histogram { my ($bucket_size, @items) = @_; my %result; for (@items) { my $bucket = $bucket_size * floor($_ / $bucket_size); # print "$bucket\n"; $result{$bucket}++; } return %result; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Working out frequency statistics with perl
by jethro (Monsignor) on Jul 16, 2008 at 14:26 UTC |