[ABE.pm] Tie::Hash-ing to files?

Ricardo SIGNES rjbs-perl-abe at lists.manxome.org
Wed Oct 18 16:22:40 PDT 2006


* "Faber J. Fedor" <faber at linuxnj.com> [2006-10-18T17:49:24]
> On 18/10/06 16:33 -0400, Ricardo SIGNES wrote:
> > 
> > If you can provide a short example that I can run to reproduce this
> > problem, I can help you fix it.
> 
> I can do that (see attached files) and I can point you to the place in the
> FlatFile.pm where the problem is occuring and why.  I just don't know
> how to fix it other than commenting out the offending lines. 

Aha!  Interesting little problem.  I've submitted the bug to MJD, along with a
patch, which I'm also attaching here.

  http://rt.cpan.org/Ticket/Display.html?id=22167

-- 
rjbs
-------------- next part --------------
--- FlatFile.pm.old	2006-10-18 19:10:08.000000000 -0400
+++ FlatFile.pm	2006-10-18 19:08:59.000000000 -0400
@@ -430,15 +430,18 @@
 
   $recno++ while $self->{DELETE}{$recno};
 
-  # Someone may have done an in-memory update of the record
-  # we just read.  If so, discard the disk data and
-  # return the in-memory version of the record instead.
-  return $self->{UPDATE}{$recno}
-    if exists $self->{UPDATE}{$recno};
-
-  # if it wasn't updated, the continue processing
-  # with the disk data
-  my $line = $self->{file}[$recno];
+  my $line;
+  if (exists $self->{UPDATE}{$recno}) {
+    # Someone may have done an in-memory update of the record
+    # we just read.  If so, discard the disk data and
+    # return the in-memory version of the record instead.
+    $line = $self->{UPDATE}{$recno}
+  } else {
+    # if it wasn't updated, the continue processing
+    # with the disk data
+    $line = $self->{file}[$recno];
+  }
+
   return unless defined $line;
   my @data = split $self->{FIELDSEP}, $line, -1;
   $self->{recno} = $recno+1;


More information about the ABE-pm mailing list