Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8188611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:58:21+00:00 2026-06-07T02:58:21+00:00

The following code prints the highest busy value in every 5 minute increment. How

  • 0

The following code prints the highest busy value in every 5 minute increment. How can I print the increment (ex. 2:15 for 02:19:09) instead of the timestamp?

my @maxima;  
    for my $record (@lastArray) {    
        my @fields = $record =~ /([^,\s]+)/g;   
        next unless @fields;    
        my @range = @fields[1..4];   
        $range[2] =~ s|(\d+):\d\d$|5*int($1/5)|e;   
        my $range = join ' ', @range;   
        my $value = $fields[5];    
        if (@maxima == 0 or $range ne $maxima[-1][0]) {     
            push @maxima, [$range, $value, $record];   
        }   
        else {     
            @{$maxima[-1]}[1,2] = ($value, $record) if $maxima[-1][1] > $value;   
        } 
    }  
    print $_->[2] for @maxima; 

Current output:

  Mon,Jun,25,02:19:09,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,02:21:09,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,02:25:10,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,02:56:10,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,03:00:10,2012,999,1,1,0,0,0,0,0,0,0,0
Mon,Jun,25,03:08:10,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,03:10:10,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,03:24:11,2012,999,1,0,1,0,0,0,0,1,0,0
Mon,Jun,25,03:37:11,2012,999,1,0,0,0,0,0,1,0,0,0
Mon,Jun,25,03:40:11,2012,999,1,0,1,0,0,0,0,1,0,0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:58:24+00:00Added an answer on June 7, 2026 at 2:58 am

    You need to work on your skills at specifying problems. You have asked several different questions to get to this point, and the main problem is that your statement of the problem is incomplete, or it changes from one question to the next.

    I am still worried that you always show the program in two halves – the processing of the input and the generation of the output – and I am sure that the two can be combined together to form a better and more reliable solution than you have achieved this way.

    Here is a variation of one of my previous answers that does what I think you want. Because you have shown only the second half of your program I can’t provide a complete solution. This code expects data to be presented in @lastArray in the same way as the code you have used already.

    my @maxima;
    
    for my $record (@lastArray) {    
    
        my @fields = split /,/, $record;
        next unless grep $_, @fields;    
    
        $fields[3] =~ s|(\d+):\d\d$|sprintf '%02d', 5*int($1/5)|e;
        $record = join ',', @fields;
        my $key = join ' ', @fields[1..4];
        my $value = $fields[5];
    
        if (@maxima == 0 or $key ne $maxima[-1][0]) {     
            push @maxima, [$key, $value, $record];   
        }   
        else {     
            @{$maxima[-1]}[1,2] = ($value, $record) if $maxima[-1][1] > $value;   
        } 
    }  
    print $_->[2] for @maxima; 
    

    output

    Mon,Jun,25,02:15,2012,999,1,0,1,0,0,0,0,1,0,0
    Mon,Jun,25,02:20,2012,999,1,0,1,0,0,0,0,1,0,0
    Mon,Jun,25,02:25,2012,999,1,0,1,0,0,0,0,1,0,0
    Mon,Jun,25,02:55,2012,999,1,0,1,0,0,0,0,1,0,0
    Mon,Jun,25,03:00,2012,999,1,1,0,0,0,0,0,0,0,0
    Mon,Jun,25,03:05,2012,999,1,0,1,0,0,0,0,1,0,0
    Mon,Jun,25,03:10,2012,999,1,0,1,0,0,0,0,1,0,0
    Mon,Jun,25,03:20,2012,999,1,0,1,0,0,0,0,1,0,0
    Mon,Jun,25,03:35,2012,999,1,0,0,0,0,0,1,0,0,0
    Mon,Jun,25,03:40,2012,999,1,0,1,0,0,0,0,1,0,0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code prints out 10 . How can I make it print out
For example the following code prints { key: 'b' } function myFunc(key, value) {
The following code, prints out Derived Base Base But I need every Derived object
I'm wondering why this code section prints out the following: print request.user.has_perm('bug_tracking.is_developer'): + str(request.user.has_perm('bug_tracking.is_developer'))
the most darndest thing! the following code prints out 'llo' instead of the expected
The following code prints This should print (b)This should print(/b) This should print <script>
The following code prints 123: >>> a = 123 >>> def f(): ... print
The following code prints [B@40545a60,[B@40545a60abc exp But I want to print abc , so
The following code prints (when invoking MyMethod): 0 0 0 1 I would expect
The following code prints null once. class MyClass { private static MyClass myClass =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.