in reply to searching a file, results into an array

Ah, this is classic split territory. Also, hashes were made for precisely this kind of thing, so let's roll that way, too. Now is as good of a time as any to give them a try, right?

The following code shows one way of doing what you want:

#!/usr/bin/perl use warnings; use strict; # read the files into a hash of ( filename => title ) my %files; while (<DATA>) { chomp; # get rid of line-ending if (my ($file, $title) = split ' ', $_, 2) { $files{$file} = $title; } } # print out the files in our hash, sorted by file name foreach my $file (sort keys %files) { my $title = $files{$file}; print "$file = $title\n"; } __DATA__ RS0029.DOC INTER UNIT HARNESS REQUIREMENT SPECIFICATION RS0036.DOC INSTRUMENT ELECTRONICS UNIT RS0037.DOC MECHANISM CONTROL ELECTRONICS RS0041.DOC IOU DESCAN MECHANISM RS0042.DOC IOU GENERIC MECHANISMS
(For convenience, I put the list of files in the code's __DATA__ section, but you'll read them from a separate file.)

The only tricky part is our split invocation, which says, "split lines on whitespace into two parts." If we're successful in splitting the current line, we get back the filename and its title, which we store in the variables $file and $title respectively. These, in turn, we store in a hash called, appropriately enough, %files.

The foreach loop shows how to read values out of the hash. I just print them out, but I trust that you can convert each into the appropraite hypertext link. Here's the code's output:

RS0029.DOC = INTER UNIT HARNESS REQUIREMENT SPECIFICATION RS0036.DOC = INSTRUMENT ELECTRONICS UNIT RS0037.DOC = MECHANISM CONTROL ELECTRONICS RS0041.DOC = IOU DESCAN MECHANISM RS0042.DOC = IOU GENERIC MECHANISMS

Cheers,
Tom