while ($theSubBuild ne 'sci.bld' || 'esel.bld' ){ system (qq(grep $theSubBuild nbsssbs//esel/bld/*.bld nbsssbs/sbc/bld/*.bld > $tempDir/otherblds3.txt)); open(FileOut2, "< $tempDir/otherblds3.txt") || die "Could not open the file : $!\n"; my @final2; my @end2; my $firstBld2; my $secondBld2; while () { push(@final2, $1)&& last if (m(\w+\.bld:\w.*)/ ); } my $finalValue2 = join(' ', @final2); ($theSubBuild, $secondBld2) = split (/:/, $finalValue2); close(FileOut2) or die("Can't close file: $!"); }