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 8212605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:48:50+00:00 2026-06-07T10:48:50+00:00

I am passing the input file location and output file location through the command

  • 0

I am passing the input file location and output file location through the command line and I am getting these errors:

Value “C:\Users\Mruppe2\workspace\Perl” invalid for option input
(number expected)
Value “C:\temp\output.csv” invalid for option output
(extended number expected)

No such file or directory at 5MinInterval2.pl line 154.

The command line input looks like this:

perl 5MinInterval2.pl -i C:\Users\Mruppe2\workspace\Perl 5 Essential
Training\MPMStats Project\error_log -o C:\temp\output.csv

Here is my code:

# This program parses a error_log for necessary information and outputs a CSV file with the highest busy value for each 5 minute interval.  

use strict;
use warnings;
use Getopt::Long;  

#Define argument types
my $input = '';
my $output = '';
GetOptions('input=i' => \$input,'output=o' => \$output); 

# Ignore theses values
my %ignorables = map { $_ => 1 } qw([notice mpmstats: rdy bsy rd wr ka log dns cls bsy: in);  

# Subroutine to pull the line containing AP22,SM22, and Apache stats
sub findLines {
    my($item,@result)=("");

    # Iterates over the lines in the file, putting each into $_ 
    while ($input) {      

        # Select only those fields that have the word 'notice'
        if (/\[notice/) {          

            # Place those lines with the word 'rdy' on the next line
            if (/\brdy\b/){
                push @result,"$item\n";
                $item="";

            }
            else {
                $item.=",";
            }

            # Split the line into fields, separated by spaces, skip the %ignorables         
            my @line = grep { not defined $ignorables{$_} } split /\s+/;    

            # More cleanup         
            s/|^\[|notice|[]]//g for @line; # remove unnecessary elements from the array

            # Output the line.  
            @line = join(",", @line);          
            s/,,/,/g for @line;
            map $item.=$_, @line;
            }
        } 
        @result
    }  

# Place the subroutine contents into an array
my @array = &findLines;
my $line;

# Create an subroutine to place the contents of AP22, SM22, and Apache in the correct order
sub Program{
    my @return = ();
    chomp @array;

    my ($dow,$mon,$day,$time,$year,$rdy,$bsy,$rd,$wr,$ka,$log,$dns,$cls,$dow2,$mon2,$day2,$time2,$year2,$val1,$mod1,$val2,$mod2,$val3,$mod3,$ap22,$sm22,$apache);
    foreach $line (@array){
    ($dow,$mon,$day,$time,$year,$rdy,$bsy,$rd,$wr,$ka,$log,$dns,$cls,$dow2,$mon2,$day2,$time2,$year2,$val1,$mod1,$val2,$mod2,$val3,$mod3) = ((split /[,]/, $line),("")x24); 
    $line = "$dow,$mon,$day,$time,$year,$rdy,$bsy,$rd,$wr,$ka,$log,$dns,$cls";

    # For lines with no variables
    if ($mod1 eq ""){
        $line = $line.","."0".","."0".","."0";
    }

    # For lines with only SM22
    if ($mod1 eq "mod_sm22.cpp" && $mod2 eq ""){
        $line = $line.",".$val1.","."0".","."0";
    }

    # For lines with only AP22
    if ($mod1 eq "mod_was_ap22_http.c" && $mod2 eq "" && $mod3 eq ""){
        $line = $line.",".$val1.","."0".","."0";
    }

    # For lines with AP22-SM22-Apache
    if ($mod1 eq "mod_was_ap22_http.c" && $mod2 eq "mod_sm22.cpp" && $mod3 eq "ApacheModule.cpp"){
        $line = $line.",".$val1.",".$val2.",".$val3;
    }

    # For lines with SM22-AP22-Apache
    if ($mod1 eq "mod_sm22.cpp" && $mod2 eq "mod_was_ap22_http.c" && $mod3 eq "ApacheModule.cpp"){
        $line = $line.",".$val2.",".$val1.",".$val3;
    }

    # For lines with AP22-SM22
    if ($mod1 eq "mod_was_ap22_http.c" && $mod2 eq "mod_sm22.cpp" && $mod3 eq ""){
        $line = $line.",".$val1.",".$val2.","."0";
    }

    # For lines with SM22-AP22
    if ($mod1 eq "mod_sm22.cpp" && $mod2 eq "mod_was_ap22_http.c" && $mod3 eq ""){
        $line = $line.",".$val2.",".$val1.","."0";
    }

    # For lines with SM22-Apache
    if ($mod1 eq "mod_sm22.cpp" && $mod2 eq "ApacheModule.cpp" && $mod3 eq ""){
        $line = $line.","."0".",".$val2.",".$val2;
    }

    # For lines with AP22-Apache
    if ($mod1 eq "mod_was_ap22_http.c" && $mod2 eq "ApacheModule.cpp" && $mod3 eq ""){
        $line = $line.",".$val1.","."0".",".$val2;
    }

    # Push the array out of the subroutine
    ($dow,$mon,$day,$time,$year,$rdy,$bsy,$rd,$wr,$ka,$log,$dns,$cls,$ap22,$sm22,$apache) = ((split/[,]/, $line),("")x16);
    push @return, ("$line\n");
    }
    return @return;
}

# Initialize the hashes
my %interval; 
my %month; @month{qw/ jan feb mar apr may jun jul aug sep oct nov dec /} = '01' .. '12';  

# Put the contents of the subroutine into an array
my @finalArray = &Program;

# Delete the first line of the array
$finalArray[0] = "";

# Create a new array without the first line
my @lastArray = @finalArray;


# Select only those lines with the highest busy count in each 5 minute interval
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];  
    my ($dow, $mon, $day, $time, $year, $rdy, $by, $rd, $wr, $ka, $log, $dns, $cls, $ap22, $sm22, $apache) = split /[,]/, $record;
    my $record2 = "$range,$rdy,$by,$rd,$wr,$ka,$log,$dns,$cls,$ap22,$sm22,$apache";
    if (@maxima == 0 or $range ne $maxima[-1][0]) {     
        push @maxima, [$range, $value, $record2];   
    }   
    else {     
        @{$maxima[-1]}[1,2] = ($value, $record2) if $maxima[-1][1] > $value;   
    } 
} 

# Print the contents to the CSV file
open my $fh, ">", $output or die $!;
print $fh "Time Interval,rdy,bsy,rd,wr,ka,log,dns,cls,ap22,sm22,apache\n";
print $fh $_->[2] for @maxima;

What am I doing wrong?

  • 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-07T10:48:51+00:00Added an answer on June 7, 2026 at 10:48 am

    Well, you did declare “input” to be an integer, by the looks of it:

    ... 'input=i' ...
    

    Perhaps you were looking for string:

    ... 'input=s' ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am passing an accountid as input from an XML file as shown, which
I am passing a textarea input boxs' contents via POST to my php file
In bash, there are multiple ways to direct input and output. For example, these
I'm passing from my view page one to five images to controller. <input type=file
passing post data using cURL requires that the name of the input. However, I
Is message passing taking place when calling a function with no input? i.e. with:
small question about C++ replace function. I'm parsing every line of text input line
I'm writing a small library that takes a FILE * pointer as input. If
I have a servlet that users post a XML file to. I read that
My Perl program takes some text from a disk file as input, wraps it

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.