Re: Reversing the order of a flat file in Perl
by "Jan Morell" <janman(at)n-jcenter.com>
|
Date: |
Mon, 3 Jul 2000 14:23:43 -0400 |
To: |
"Romek aka webadmin" <www(at)wipos.p.lodz.pl> |
Cc: |
<hwg-languages(at)hwg.org> |
References: |
lodz |
|
todo: View
Thread,
Original
|
|
Hi Romek,
Thank you for your input. I was able to get the results that I wanted using
your template. Here is the final code that did the trick.
open(mall_temp, ">$mall_temp");
print(mall_temp "<a href=\"$Contact_URL\"
target=\"_blank\">$Contact_URL</a><br>$SiteDescription<br>\n");
close(mall_temp);
open(mall_listing, "$mall_listing");
open(mall_temp, ">>$mall_temp");
while (<mall_listing>) {
chomp;
print (mall_temp "$_\n");
}
close(mall_temp);
close(mall_listing);
rename ($mall_listing, $mall_temp);
I found that the delete function was not required as the rename took care of
that.
Thanks again,
Jan
----- Original Message -----
From: "Romek aka webadmin" <www(at)wipos.p.lodz.pl>
To: "Jan Morell" <janman(at)n-jcenter.com>
Cc: <hwg-languages(at)hwg.org>
Sent: Sunday, July 02, 2000 12:56 PM
Subject: Re: Reversing the order of a flat file in Perl
At 09:31 02-07-00 -0400, you wrote:
>Hi Listmembers,
>
>Does anyone know of a way to "append" to the head of a flat file instead of
>end?
I do not know Perl to be more specific.
Open temporary file temp1.txt
Copy content of URL 3 part to that file.
Open file.txt
Copy/Append content of the file.txt to temp1.txt
Close temp1.txt file
Erase file.txt
Rename temp1.txt to file.txt
>
>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
--
Romek
~~~~ PeCetologia to nauka doswiadczalna � ~~~~
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA