#!/app/gmd/bin/perl use strict; my $rrcp_samp_tot = 0; my $sample = 0; # number of samples you have my ( $chour, $cmin, $csec ); my ( $lhour, $lmin, $lsec ); while ( <> ) { if ( $_ =~ /\s*([\d]+)\:([\d]+)\:([\d]+)\s*up/ ) { $chour = $1; $cmin = $2; $csec = $3; print "$lhour:$lmin:$lsec,$rrcp_samp_tot\n" if ( $sample > 0 ); $rrcp_samp_tot = 0; # reset for the next round $lhour = $chour; $lmin = $cmin; $lsec = $csec; $sample++; } if ( $_ =~ /\d*\s*\w*\s*\w*\s*[\-\w]*\s*\w*\s*\w*\s*\w*\s*\w*\s*[\<\>\-\_]*\s*([\d\.]*)\s*[\d\.]*\s*[\d\:]*\s*[\w\d\-]*\s*([\w\d]*)/ ) { # print "Sample: $1:$2\n" if ( $2 eq "rrcpd"); my $cpu = $1; $rrcp_samp_tot += $cpu if ( $2 eq "rrcpd" ); next; } } print "$lhour:$lmin:$lsec,$rrcp_samp_tot\n" ; # to print the last sample