in reply to FlatFile Sort Help

If your file is small enough to read into memory, you could sort your input as you read it in:

foreach (sort <LOOPFILE>) {...}

Also, be aware that the last element in @lineitems will still contain a newline character.

--MidLifeXis

Replies are listed 'Best First'.
Re^2: FlatFile Sort Help
by Anonymous Monk on Nov 05, 2008 at 19:13 UTC
    Thanks for the reminder about the \n and for the reply. Would I be able to do something like this then?

    while (<LOOPFILE>) { foreach (sort <LOOPFILE>) { $linenumber ++; @lineItems = split (/\t/); #... print OUTFILE "<BR><B>$lineItems[0]</b> ($lineItems[1])\n"; #.... } } require "footer.pl"; close (LOOPFILE);
    Thank you...and and sincerely appreciate the help and please don't giggle, I'm trying to jog what little memory I have.
      Remove the while.
      while (<LOOPFILE>) { # Reads first line foreach (sort <LOOPFILE>) { # Reads the rest of the line.

      So you'll end up printing everything but the first line.

      Drop the while loop and you should be fine.