Certainly... I should have done that..
#!/usr/bin/perl
&processf();
use Fcntl ':flock';
sub processf() {
unless (open(FILER, "ts-speed.txt")) {
die ("cannot open input file out2\n");
}
$newfile="final.out";
flock FILE, LOCK_SH;
while ($line=<FILER>) { # first loop starts here..
chomp($line);
my $mymac = substr($line, 0, 12);
unless (open(FILER2, "docsis-file-orig")) {
die ("cannot open input file out1\n");
}
while ($item=<FILER2>) { # second loop starts here....
chomp ($item);
$mymac1 = substr($item, 0, 12);
if ($mymac =~ /^$mymac1$+/g) {
unless (open(FILEW, ">>$newfile")) {
die ("cannot open input file newfile\n");
}
flock(FILEW, 2); # file lock set
printf("'%s' and '%s' are identical\n", $mymac, $mymac1);
print FILEW ("$item $line\n");
flock(FILEW, 8); # file lock unset
close(FILEW);
} #if end here;
} #while second end here;
close(FILER2);
} #while first end here;
close(FILER);
} #sub end here;
| [reply] |