Thank you, that solved a large part of my problem. The only issue remaining now is that in files 'host' and 'host1', it only inserts the first line from file3 and leaves it out for subsequent lines.
The output currently looks like this for 'host':
SR-IT-SD4546-IBV-sw947-A
SR-IT-SD4546-IBV-sw908-A
SR-IT-SD4748-IBV-sw-A
SR-IT-SD4748-IBV-sw-A
and like this for 'host1':
SR-IT-SD4546-IBV-sw947-B
SR-IT-SD4546-IBV-sw908-B
SR-IT-SD4748-IBV-sw-B
SR-IT-SD4748-IBV-sw-B
The code has been modified to look like this:
open(MYINPUTFILE, "file1");
open(MYINPUTFILE1, "file2");
open(MYINPUTFILE2, "file3");
open(HOST, ">host");
open(HOST1, ">host1");
while (<MYINPUTFILE>) {
my($line) = $_;
chomp($line);
for ($numsw = $swnum; $numsw > 0 ; $numsw-- ){
my $line1 = <MYINPUTFILE1>;
chomp($line1);
my $line2 = <MYINPUTFILE2>;
chomp($line2);
print HOST "SR-$line1-SD$line-IBV-sw$line2-A\n";
print HOST1 "SR-$line1-SD$line-IBV-sw$line2-B\n";
open (OUTHANDLE, ">>$line2");
print OUTHANDLE "SR-$line1-SD$line-IBV-sw$line2-A\n";
print OUTHANDLE "SR-$line1-SD$line-IBV-sw$line2-B\n";
close (OUTHANDLE);
seek (partner,0,1);
seek (switchid,0,1);
}
}
close (MYINPUTFILE);
close (MYINPUTFILE1);
close (MYINPUTFILE2);
close (HOST);
close (HOST1);
This is the last issue I have to solve before being able to use this for production work, so any additional help is greatly appreciated.