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

  • Home
  • SEARCH
  • 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 8196567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:31:23+00:00 2026-06-07T05:31:23+00:00

I have program that prints the highest interval every 5 minutes. I have previously

  • 0

I have program that prints the highest interval every 5 minutes. I have previously used this same format with another similar array, but I am getting a few errors this time:

  • Use of uninitialized value $min in division …
  • Use of uninitialized value $yr in sprintf …
  • Use of uninitialized value in sprintf at …

    use strict;
    use warnings;
    use Text::CSV_XS;
    
    my %interval; 
    my %month; @month{qw/ jan feb mar apr may jun jul aug sep oct nov dec /} = '01' .. '12';  
    
    foreach my $line (@lastArray){          
            $line =~ s/$/,/;
            my ($dow, $mon, $day, $hr, $min, $sec, $yr, $amt) = split /[:,]/, $line;   
            my $key = sprintf "%4d-%02d-%02d %02d:%02d",                 
                $yr, $month{lc $mon}, $day, $hr, int($min / 5) * 5;      
                if (exists $interval{$key}) {         
                    if ($interval{$key}{amt} > $amt) {             
                        $interval{$key}{amt} = $amt;             
                        $interval{$key}{data} = [split ",", $line];         
                    }     
                }     
                else { # first time in this 5 minute interval         
                $interval{$key}{amt} = $amt;         
                $interval{$key}{data} = [split ",", $line];     
                }
        }   
        my $csv = Text::CSV_XS->new ({ binary => 1 }) or die "Cannot use CSV: ".Text::CSV_XS->error_diag ();  
        $csv->eol("\n");
    
        # Initialize CSV files  
        open my $fh, ">", 'log_5min.csv' or die $!;  
        open my $FILE, ">", 'last_5min.stat' or die $!;
    
        # Print Max Busy for all intervals
        print $fh "DayofWeek,Month,Day,Time,Year,rdy,bsy,rd,wr,ka,log,dns,cls\n";
        for my $time (sort keys %interval) {   
            $csv->print($fh, $interval{$time}{data}); 
        }  
    

The array @lastArray contains the following:

Wed,Jun,13,01:00:29,2012,777,23,0,15,6,0,0,2,15,0,0
Wed,Jun,13,01:01:29,2012,782,18,0,14,3,0,0,1,14,0,0
Wed,Jun,13,01:02:29,2012,787,13,0,10,3,0,0,0,10,0,0
Wed,Jun,13,01:03:29,2012,782,18,0,15,2,0,0,1,15,0,0
Wed,Jun,13,01:04:29,2012,779,21,0,12,9,0,0,0,12,0,0
Wed,Jun,13,01:05:30,2012,777,23,0,18,5,0,0,0,18,0,0
Wed,Jun,13,01:06:30,2012,783,17,0,10,4,0,0,3,10,0,0
Wed,Jun,13,01:07:30,2012,786,14,0,6,5,0,0,3,6,0,0
Wed,Jun,13,01:08:30,2012,789,11,0,6,5,0,0,0,6,0,0

How can I fix the errors? Thank you for your help.

  • 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-07T05:31:24+00:00Added an answer on June 7, 2026 at 5:31 am

    “Use of uninitialized value $min in division”: One of the values in @lastArray has fewer than 3 “:” or “,”.

    “Use of uninitialized value $yr in sprintf”: One of the values in @lastArray has fewer than 6 “:” or “,”

    etc.

    PS – Get rid of $line =~ s/$/,/;. It doesn’t do anything useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C program that prints every environmental variable, whose name is given
I have this little program that prints out all of the supported providers in
I have a program that when I run, it prints something like this in
I have a command line program that prints out a report such as: I
I have one application that prints messages from Test.exe in console .My java program
I have a program that generates a PDF as output. If I send this
I have a (java) program that prints a line of hex numbers to stdout
So i have this program that should solve a futoshiki puzzle in C wich
I have a Java program that creates a file and prints a bunch of
I have a program that prints out the location of commas in a paragraph

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.