On Sat, 24 Jan 2004 17:41:13 -0700
danield <[EMAIL PROTECTED]> wrote:

>
> 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:

<snip>
I think I understand your request.

Just try this. It reads line by line and has the three "if" conditions for a print. 
See if you can adapt that to your script. Also, chomp is preferred to chop.
-------------------------------------------------------------
#!/usr/bin/perl

#use strict, etc as required as per your original script

while(<DATA>){
print if((/Summary Log/) and (/Apr/) and (/2003/))
    }


__DATA__
Summary Log (generated: The Apr  1 22:02:29 MST 2003)
Summary Log (generated: Tue May  1 22:02:29 MST 2003)
Summary Log (generated: Tue Jun  1 22:02:29 MST 2003)
Summary Log (generated: Tue Apr  1 22:02:29 MST 2004)
Summary Log (generated: Tue Apr  1 22:02:29 MST 2004)
Summary Log (generated: The Apr  1 22:02:29 MST 2003)
-- 
Owen


-- 
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