I'm creating a file which is just an ASCII text file, but I'm writing
fixed length records into it. At any time, I need to reopen the file and
write a record to a byte position calculated at run time. The write
position will frequently be beyond the end of the current file length,
so I need for the file to be extended.
In the test code below, I have replaced the calculated position with
"128" for convenience. When I run the code, it creates the file, and it
says that the current position is "128", but when I write the record, it
always ends up at the very beginning of the file.
Any clue as to what I am doing wrong?
------------------------------------------
use warnings;
$MAILSTATS = '+>>mailstats.dat';
if (open MAILSTATS)
{
if (seek MAILSTATS, 128, 0)
{
print "Current file position is ", tell(MAILSTATS), "\n";
print MAILSTATS "This is a test record.";
}
else
{
print " Can not seek to location 128.\n";
}
close MAILSTATS;
}
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs