in reply to (jeffa) 3Re: Searching for variable then blank lines
in thread Searching for variable then blank lines
Thanks to everyone who has helped me on this. I must be dense. :-\ Now I am getting my script to read in my file and go down to the beginning of the line starting with ARCSERVE.NLM, and it gives me *every* line after that. My script is not not exiting when it finds the first 2 returns after ARCSERVE.NLM for the first time. Below is my script and a sample of the output file.
This is just an example. My file was much larger than this. I was not wanting the information starting with ASDB.NLM to the end of the file. What do I need to do to make this happen?use strict; use File::Basename; ##******** Variables ********## my $filepath = 'c:\a\netware'; my $dump = 'Netware_hw.txt'; my $arc = 'ARCSERVE.NLM'; my $serverfile = 'dallas.txt'; open (SERVER, "<$serverfile") or die "Can't open the file\n"; open (OUTPUT, ">>$filepath\\$dump"); my @lines= <SERVER>; my ($s, $b); foreach my $line (@lines) { if ($line =~ /^\n$/) { $b++; last if (($b == 2) && $s); } else { $b = 0; } if ($line =~ /$arc/) { $s = 'true'; } if ($s) { print OUTPUT $line; } } close (OUTPUT); close (SERVER); =========== OUTPUT FILE =========== ARCSERVE.NLM Version: 1 Date: 10/22/2000 ID: 000 Parent ID: x Type: UNKNOWN Description: ARCserve Flags: ASDB.NLM Version: 2 Date: 12/8/2000 ASPIBD.NLM Version: 4 Date: 12/15/2000 ID: 0
Thx again!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Exiting when parsing files
by jeffa (Bishop) on Mar 15, 2002 at 15:05 UTC |