How big are the files? If they are not too large, I would suggest reading each file into a hash, then create a new file if the right parts of the two hashes match.
Do you only want to merge the data if the line ends in something other than a number, or is it OK to merge if they both end in the same number? Something like this pseudo code open file 1 open file 2 while <file 1> { split line into $pre,$data and $post elements $hash1{$pre) = $pre; $hash1{$pre}{'data'} = $data; $hash1{$pre}{'post'} = $post; } do the same split/store for file 2 open file 3 for writing foreach $key(keys %hash1) { do tests here e.g if $hash1{$key}{'post'} eq $hash2{$key}{'post'} (this will check that the same beginning and end match in the two hashes) If you get a match then print FILE3 "$pre,$hash1{$pre}{'data'},$hash2{$pre}{'data'}\n"; } HTH John -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 02 October 2001 17:03 To: [EMAIL PROTECTED] Subject: append line Hi all, I have 2 files comma delimited that I want to merge based on similarity of first and last entry file1 looks like this alpha,1,2,3,K delta,3,4,5 file2 looks like this: beta,2,3,4 alpha,33,22,35,K the output I am looking for is: alpha,1,2,3,33,22,35 basically I want to append content of a line of file 1 if the first element and last element are same in both files is same . Thanks for your help I.S __________________________________________________________________ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------Confidentiality--------------------------. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]