Ned -- ...and then Ned Cunningham said... % % OOPS :-( % I wanted to sort the file that I am writing, by the second element in @DATA?
OK. You're also writing out a count number, it looks like: % Snip % open CUST, $cust or die "Cant open it :$!"; % open WRFILE, ">$wrfile"; % % while (defined ($line = <CUST>)) { % % % chomp $line; % @data = split(/\|/,$line); % $newnum=$newnum+1; % printf WRFILE ("0%9d",$newnum); % % print WRFILE ";", @data, ";"; % print WRFILE "\n"; % } So for input a|b|c|d e|f|g|h i|a|a|a you generate 1 a b c d 2 e f g h 3 i a a a with the code above, right? It seems like there ought to be a cleaner way, but you could always suck in the whole file, prepending your incrementing counter as you go, and then print the sort based on the proper element (now the third, mind you) and then print the results out to your WRFILE... You'll have to have the entire CUST file in memory in order to sort anyway, so it shouldn't be too terrible to suck it in. HTH & HAND :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
msg25224/pgp00000.pgp
Description: PGP signature