|
Hi,
I have added the following lines of code for locking the file.
I see a new problem after the following code is executed, the XML file is completely blank.
If I remove the file locking code the XML is atleast populated.
However the xplorer still used to crash -both with file locking and without file locking.
Can any one point out what is wrong in this code ? Or how to debug ?
I am using IIS web server.
# Save user name and email
# Inserting the submitted info
my $node = XML::Twig::Elt->new(
'User', {'name' => $usr},
XML::Twig::Elt->new( 'email' => $email )) ;
$node->paste( last_child => $twig->root ) ;
#use lock to write into the file
sysopen( FH, $registerFile, O_RDWR )
or die "can't open $registerFile: $!";
flock( FH, LOCK_EX)
or die "can't lock filename: $!";
truncate(FH, 0) or die "can't truncate filename: $!";
$twig->print_to_file( $registerFile ) ;
close(FH)
|