Hello all,

I do have file where is:

 Summary Log (generated: Tue Apr  1 22:02:29 MST 2003)

And I do have a script which goes through this file line by line. The
first 'if' condition checks whether I have found the line I am
interested in (Summary log...) The second 'if' then should check whether
the month is "Apr" and the year is "2003". The script as it is now is
not correct, since it evaluates the first condition and splits line into
variables and then skips the second if.

The script looks like:

#!usr/bin/perl -w

use strict;
use Fcntl qw[:flock];

my $impressions = 0;
my $iofile = '/other/scripts/daniel/input/c07_impressions_io.info';

open (IO, $iofile) || die("Could not open file 1!");

while (<IO> ) {
      chop;
      (my$FH, my$output, my$file2check, my$month, my$year) = split
(/\s+/, $_);

#open OUT, ">> $output";

chdir $FH or die "$!";

while (glob $file2check) {
    open FH, $_ or die $!;
    flock FH, LOCK_SH or die $!;
    while (<FH> ) {
        chomp;
        if ( / Summary Log \(generated:/ ) {
            (my$emptyspce, my$summary, my$log, my$generated, my$day_word,
my$monthfile, my$day_number, my$time, my$timezone, my$yearfile ) =
split(/\s+/, $_);
        #print "File $file2check is $monthfile, $year\n";
            if ($monthfile eq $month
                and $yearfile eq $year){
                print "File has this year: $yearfile and month: $monthfile in it.\n"}
                }
           }
    close FH or die $!;
    }
# print OUT 'Total impressions: ', $impressions or die $!;
  } 

Thank you for your time.

danield


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to