Hi guys,
I have a several dozen .ini files from which I need to extract specific lines. The lines I'm pulling are repeated all throughout the code so I can't count on specific strings to pull these lines. My dilemma is that I want lines: 3, 4, 6, 47, 50, 60, 61, 63, ****and then 3, 4, 6 again*****, then 80, 83, 93, 94, 96. Unfortunately the code I have goes only in sequential order and I can't just enter lines 3, 4, 6 in between lines 63 and 80. Can anyone think of a way to do lines 3,4,6,47,50,60,61,63,3,4,6,80,83,93,94,96?
Thanks
use strict;
use warnings;
my $dir="c:\\input";
my $outputdir="c:\\input\\output";
my @files=`dir /b $dir\\C*.ini`;
my @lines=qw(3 4 6 47 50 60 61 63 80 83 93 94 96);
my %line;
for (@lines){
$line{$_}=1;
}
my $count=0;
for (@files){
s/\r//g;
s/\n//g;
open(FILE,"<","$dir\\$_");
open(OUT,">","$outputdir\\$_");
while(<FILE>){
$count++;
chomp;
if($line{$count}){
print OUT "$_\n";
}
}
$count=0;
close FILE;
close OUT;
}