Anand Babu wrote:

> No, I was not expecting anyone to give me a ready made program! I believe in the 
> adage that "Self Help is the Best Help":-)
>

Good.  You will find a lot of help, then.

> Thanks
>
> Anand
>
> ---------
>
> The script:
>
> ------------
>
> #!/usr/bin/perl
>
> use Getopt::Long;  #note dropped blank line
> use Time::Local;
>
> my $file="access_log_modified";
> my $line;
> my $count;
> my $begin_time = "";
> my $end_time;
>
> my %seen = ();
> my @visual_pages = ();
> my ($datetime, $get_post, $Day, $Month, $Year, $Hour, $Minute, $Second);
> my $interval = 60; #An interval of 1 minute

You are setting yourself up for failure right here, by declaring all of these as 
globals, so far from the context in which they will be used.  Before you try to do 
power
programming, you must use simple programs to practice the skills of passing variables, 
both by value and by reference.

> my @pages_processed;
>
> count_recs();
>
> sub count_recs {
>
> open (INFILE, "<$file") || die "Cannot read from $file";
>
> WHILELOOP: while (<INFILE>) {
>

Okay, I'm going to stop right here, because we already see a problem that you should 
address before you ask others for help.

Indentation is crucial in code writing.  When you have any execution block, all lines 
within should be indented by some standard number of spaces.  The number is a matter of
personal preference, but should be consistent throughout a script.

sub count_recs {
    open (INFILE, "<$file") || die "Cannot read from $file";
WHILELOOP:         # Get rid of this.  It is clunky, and should be unnecessary
    while (<INFILE>) {
        $line = $_;
        chomp;
        ($datetime,$get_post) = (split / /) [3,6];
        ...
    }
    ...
}
# Using a 4-space standard for indentation
It is really not fair to ask others to try to understand and help you with your work 
unless you can take the time to make the spacing and indentation of your program
meaningful.

Please take some time, perhaps switch to a good code editor [NOT word processor] with 
auto-indent features, and reformat this code so that it conveys the flow of execution 
more
clearly.  cut pout the blank lines that are meaningful.

Move the declarations for your variables into the naroowest scope that will still 
allow access when needed.  Note which ones still have to be globals, because that will 
be the
next task to take up.

Then post your modified, more communicative code, and we will work with you to polish 
it and develop it further.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to