I am trying to write a script that will read in a file into an array line by line. When it gets to the line starting with arcserve.nlm, I want my script to put that line and all other lines after that one until it reaches 2 blank lines into a temporary file. This arcserve.nlm will be somewhere in the middle of the file, but the line will start with arcserve.nlm.
Please help! I am having problems jumping to the line beginning with arcserve.nlm, then starting my conditions with this line, giving me every line until I reach 2 blank lines together. Below is what I have started:
use strict; use File::Basename; ##******** Variables ********## my $filepath = 'c:\a\netware'; my $dump = 'Netware_hw.txt'; my $arc = 'ARCSERVE.NLM'; my $serverfile = 'dallas.txt'; opendir (SOFTWARE, "$filepath"); chdir $filepath; open (SERVER, "<$serverfile") or die "Can't open the file\n"; open (OUTPUT, ">>$filepath\\$dump"); print OUTPUT "$name~"; my @lines= <SERVER>; foreach my $line (@lines) { if ($line =~ m/$arc/) { split(/^\n/; print OUTPUT "$line~";} } } close (OUTPUT); closedir (SERVER); closedir (SOFTWARE);
In reply to Searching for variable then blank lines by rscott212
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |