Why use 'seek' at all? You have already opened the file in 'append mode'
which should bring you to the bottom of the file.
The '2' in flock may depend on what system you are on. It generally means
'exclusive' lock.
Also, I usually use the 'each' function to iterate through a hash...
****************************************************************************
**
open(DATA, ">>formparser.data") or die ("Cannot open formparser.data: $!");
flock(DATA,2);
while ( ($mykey,$myvalue) = each(%form) ) {
print DATA "$myvalue:";
}
close (DATA);
****************************************************************************
***
-----Original Message-----
From: byron wise [mailto:[EMAIL PROTECTED]]
Sent: May 2, 2000 9:06 AM
To: Perl-Win32-Users Mailing List
Subject: writing to file??
I need to append a line to the end of a file. I have the data in a hash
(%form). Each element in the hash will be seperated by a colon and the
entire hash will comprise a single line entry in the file. Will the
following work? Is there a better way?
****************************************************************************
***
open(DATA, ">>formparser.data") or die ("Cannot open formparder.data: $!");
flock(DATA,2); //What is the 2?
seek(DATA,0,2); //I'm still not sure what this does.
foreach $key (keys %form) {
print DATA "$form{$key}:"; }
close (DATA);
****************************************************************************
***
Many thanks,
Byron Wise
Fear is the path to the dark side. Fear leads to anger, anger leads to
hate, hate leads to suffering.
-=[Yoda]=-
_______________________________________________________
Get 100% FREE Internet Access powered by Excite
Visit http://freelane.excite.com/freeisp
---
You are currently subscribed to perl-win32-users as:
[EMAIL PROTECTED]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]