HELP: File corruption on opening. 
Author Message
 HELP: File corruption on opening.

Hi all,

Could anyone possibly shed some light on a little problem im having.

Im attempting to open a datafile (simple fixed width fields database file).
However as soon as its opened its getting corrupted.

im using the following lines of code to open the file

$dbname = "orders.dat";

sysopen(ORDERS,$dbname,2);

close(ORDERS);

Ive got the use Fcntl ':flock'; line at the start of my code so its picking
up on that ok.

Basically without doing any sort of reading or writing to the datafile it
corrupts the database.  It appears to chop each line into three parts.  The
first part of each line gets written to the start of the file, the middle
part of each line ends up in the middle of the file and the end parts get
mainly written to the end of the file.

Ive got code elsewhere in the script that opens another datafile and reads
it in fine, but as soon as my perl script touches the orders.dat file it
goes pear shaped.

Ive also tried to open the file using the standard open (ORDERS,
">$dbname"); line but the same problem occurs.  This is also happening if I
attempt to open it in read only mode.

Please help me before I remove what little remains of my hair and my sanity
finaly takes a leave of absence.

Andy.



Tue, 02 Mar 2004 12:08:59 GMT  
 HELP: File corruption on opening.

Quote:

>Im attempting to open a datafile (simple fixed width fields database file).
>However as soon as its opened its getting corrupted.

>im using the following lines of code to open the file

>$dbname = "orders.dat";

>sysopen(ORDERS,$dbname,2);

You really should use the symbolic constants exported by the Fnctl
module. Have you read perlopentut yet? Try "perldoc perlopentut" if
you haven't done so yet.

What is it exactly you're trying to do?

Questions, questions...
--

split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while



Tue, 02 Mar 2004 13:10:47 GMT  
 HELP: File corruption on opening.

Quote:

>Hi all,

>Could anyone possibly shed some light on a little problem im having.

(bizzare problem snipped)

create the shortest possible script that exhibits your problem,
and post it here so we can see what you are doing.
there is a good chance that just by doing that, you will find your bug.

gnari



Tue, 02 Mar 2004 18:16:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Need help testing a gzip file for corruption

2. file corruption from an unknown source

3. DBM file corruption

4. CGI::Lite file upload corruption

5. Binary file corruption

6. open FILE,$path || open FILE,$altpath;

7. HELP: FILE OPEN/READ/SEARCH help

8. File Opening Help

9. Need help opening file, retuning data

10. Help opening a file

11. HELP: Opening file for appending

12. Help opening a file

 

 
Powered by phpBB® Forum Software