Thankyou for all your help over the last couple of days. I do really appreciate it!

But, I'm afraid I am still stuck in the mud.

I was just wondering... how would you go about doing what I'm trying to do and getting it to work??

What I have is a number of files in a directory. My search script works through each of these files and if a word within a file matches that of the search criteria then I need to mark that file as a result.

I then need to enter another routine where the script opens up each file in the results array or hash or whatever and prints out the details of that file. However I need the files to be printed in alphabetical order. The order will be determined from the information within the individual files.

I have had no luck sorting these so far. Does anyone have any last thoughts before this monitor gets thrown out of my window?

Heh, I've been struggling with a similar problem myself this afternoon! Found some help in Perlfaq4 under Data:Arrays/How do I sort an array by (anything). Here's a working example: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

This will work for you, too. Just populate an array with filename-keyword pairs, delimited with (a) suitable character(s), and modify the regex on line 4 accordingly.

If someone could explain how this works, I'd be happy. I can't understand how $a and $b can be used as references for a seemingly unrelated array. Another example in Perlfunc is even more confusing, where $a and $b seem to be used both as references and string variables at the same time. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

Any idea how I can push my two variables into an array then? I have the first which is $dat_id and the second $e_dat_name. Any ideas how to push these onto an array and then modify the code accordingly?

These work with the previous example as long as the the arrays don't contain semicolons.

Have a nice day.

P.S. Forgot about the regex. You need to figure out a regular expression that mathces the part in each array element that you want it sorted by: /firstpart;(whatyouwant)/ . I can't help with it without knowing the dataset. Strongly recommend reading up on regular expressions if you haven't done so yet. See O'Reilly's Camel and Llama books. The online manual that comes with ActivePerl is great too.