Hi
I have a log file, I am having problem with "if else" loop in my perl script which does, find a string in that file ,If that string is found append to success.txt else append it to failed.txt.
problem is:
else part of loop it is not working
I am adding problem part of the script.
=====================================
sub log2960 {
$s1 = $c1;
@c2960 = ("cp c2960-lanbase-mz \/ftpboot\/$u\/c2960-lanbase-mz",
"cp c2960-lanlite-mz \/tftpboot\/$u\/c2960-lanlite-mz",
"cp c2960-th0-mz \/tftpboot\/$u\/c2960-th0-mz",
"cp c2960-th-mz \/tftpboot\/$u\/c2960-th-mz",
);
if ( $s1 == "b" ) {
# log c2960
$log = "\/users\/$u\/c2960-log.txt";
open(FILE, $log) || die "cud not read $log";
while (<FILE>) {
if (/$c2960[0]/) {
print "$c2960[0]\n";
open(OUTFILE,">>$of1") || die "cud not write";
print OUTFILE "c2960-lanbase-mz\n";
close(OUTFILE);
last;
[problem] }else{
open(OUTFILE,">>$of2") || die "cud not write"; print OUTFILE "c2960-lanbase-mz\n";
close(OUTFILE);
last;
}
} #End of while
close(FILE);
#crypto log c2960
$log = "\/users\/$u\/c2960-crypto-log.txt";
open(FILE, $log) || die "cud not read $log";
while (<FILE>) {
if (/$c2960[5]/) {
print "$c2960[5]\n";
open(OUTFILE,">>$of1") || die "cud not write";
print OUTFILE "c2960-lanlitek9-mz\n";
close(OUTFILE);
last;
[problem] } else {
print "NO $c2960[5]\n";
open(OUTFILE,">>$of2") || die "cud not write"; print OUTFILE "c2960-lanlitek9-mz\n"; close(OUTFILE);
last;
}
}
close(FILE);
return;
}
}
==========================================
Could anybody please suggest other way, if it does not work.
Thanks
Amit
