You're using an awfully complicated method to pick the desired filenames.. The following will suffice:
my @hold2 = map /(\w+\.bld)/, <OUTother>;
Note however that egrep expects only a single, first argument to be an expression to search for. So it interprets the array elements of @hold2 other than the first one as names of files to examine.. what you want to do is to construct a regex:
my $hold2 = join "|", @hold2;
`egrep -wn '$hold2' nbsssbs//esel/bld/*.bld nbsssbs/sbc/bld/*.bld nbss
+bts/btsc/bld/*.bld > $temp/otherblds2.txt `;
Which you can roll into the map at the top. That makes:
my $hold2 = join "|", map /(\w+\.bld)/, <OUTother>;
But why use backticks when you're throwing the program's output away anyway?
system "egrep -wn '$hold2' nbsssbs//esel/bld/*.bld nbsssbs/sbc/bld/*.bld nbssbts/btsc/bld/*.bld > $temp/otherblds2.txt" or die "egrep failed: $!";
Since you're outputting the results to a file in a tempdir, I suspect you go on to read them back in later - that would be an awfully roundabout way of doing what you want. Instead, you can open a pipe to it:
open EGREP, "egrep -wn '$hold2' nbsssbs//esel/bld/*.bld nbsssbs/sbc/bl
+d/*.bld nbssbts/btsc/bld/*.bld |" or die "Pipe to egrep failed: $!";
my @othersblds = <EGREP>;
close EGREP;
Now your desired data should be in @otherblds. That gives us:
open(OUTother, "<", "C:/Perl/MyScripts/tmp.txt") or die "Couldn't open
+ file: $!";
my $hold2 = join "|", map /(\w+\.bld)/, <OUTother>;
close OUTother;
open EGREP, "egrep -wn '$hold2' nbsssbs//esel/bld/*.bld nbsssbs/sbc/bl
+d/*.bld nbssbts/btsc/bld/*.bld |" or die "Pipe to egrep failed: $!";
my @othersblds = <EGREP>;
close EGREP;
Of course if you really do want the tempfile, use the system call instead.
Makeshifts last the longest. |