Reversing the order of a flat file in Perl

by "Jan Morell" <janman(at)n-jcenter.com>

 Date:  Sun, 2 Jul 2000 09:31:38 -0400
 To:  <hwg-languages(at)hwg.org>
 References:  chronotope hwg
  todo: View Thread, Original
Hi Listmembers,

Does anyone know of a way to "append" to the head of a flat file instead of
end?

I am creating a listing in which the output of a flat database file is read
into an HTML page using SSI.  The file is created by a form and each entry
is now appended to the end of the database.  I would like the new entry to
be written to the head of the file instead.  "Reverse Cronology" so to
speak.

I am on a UNIX server, running Apache and Perl 5.004.

As an alternative I was thinking of trying to write a Perl routine to
reverse the order of the file and call that in the SSI instead of just
importing the file, but I would rather get the import file in the order that
I want first so that I don't have to call another script to get the same
results.

Example:

Now the database looks like this:

URL 1<br>Description1<br>
URL 2<br>Description2<br>
URL 3<br>Description3<br>

I want it to look like this:

URL 3<br>Description3<br>
URL 2<br>Description2<br>
URL 1<br>Description1<br>

Thanks in advance for any help.

Jan

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA