in reply to Reading a Directory of Files, Searching for Text, Outputting Matches

I'm not sure I can provide a complete solution, since I have no idea what is comming in on the command line, and what the data is.

You get the filenames into @all_file_names but all you do is to write those to index.txt, you do not appear to do anything else with the files - or maybe I misunderstand.

However you have some strange constructs which tidying up and might make your code clearer.
use strict;
There are several variables that are used inside the main loop. Are these supposed to be globals? Declaring them with my will make their scope clearer (that might solve part of your problem).

In a couple of places you have code like this:
select directory1; print "$path\n";
which is rather unnecessary. It would be simpler to:
print directory1 "$path\n";
Be careful of your opens:
open Contract1, "<./$_ \n"; # What's with the space and new-line? my @lines = <Contract1>; close Contract1; my $contents = join "", @lines;
Perl will look in the current directory anyway (no need for ./), and you should always test the open. Could be written as:
open Contract1, '<', $_ or die "Unable to open $_: $!"; local $/ = undef; # slurp mode my $contents = <Contract1>; # Hope the files are small! close Contract1;
You place an undef element onto the array, then shift it off:
@all = undef; shift @all;
Would be simpler if you did this:
my @all;
Which you would have done if you use strict;

I'm not sure that you actually need to do a multi-line match and store everything, but then again I don't know what the data looks like.