X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=bibliofile%2Fparse_dbd.pl;h=3b5450bf93495f1b961b3723c8d3853d27c01b53;hp=f72347c48e5c803599ca6bb77b71814480c7b5a1;hb=c9e2deadd0818d7c14c206e5f26b78b8a92085fd;hpb=500f5ae6ff4d8e363f78f8727611f0a54d84c649 diff --git a/bibliofile/parse_dbd.pl b/bibliofile/parse_dbd.pl index f72347c..3b5450b 100755 --- a/bibliofile/parse_dbd.pl +++ b/bibliofile/parse_dbd.pl @@ -1,5 +1,21 @@ #!/usr/bin/perl -w +# Copyright 2009-2012, Equinox Software, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + use strict; $/ = undef; @@ -14,7 +30,7 @@ my $startOfColumnTypes = 8; while (<>) { my $dbd = $_; - my $rowlength = ord substr($dbd, 0, 1); + my $rowlength = ord(substr($dbd, 0, 1)) + (256 * (ord(substr($dbd, 1, 1)))); my $numcolumns = ord substr($dbd, 2, 1); my $extra = sprintf( "%02x %02x %02x", @@ -30,15 +46,15 @@ while (<>) { my $colnames = substr($dbd, $startOfColumnTypes + 7*$numcolumns - 2); my @col = split(/\x00/, $colnames); - #print "Row length: $rowlength\n"; - #print "Columns: $numcolumns\n"; - #print "Extra data: $extra\n"; - #print "Delimiter: $delimiter\n"; + print "Row length: $rowlength\n"; + print "Columns: $numcolumns\n"; + print "Extra data: $extra\n"; + print "Delimiter: $delimiter\n"; for (my $i = 1; $i <= $numcolumns; $i++) { my $coltype = substr($dbd, 7*($i-1)+$startOfColumnTypes, 1); my $collength = ord substr($dbd, 7*($i-1)+$startOfColumnTypes+1, 1); - printf ("Column %0" . length($numcolumns) . "d: %-8s %s (%d chars)\n", $i, $coltypes{$coltype}, $col[$i-1], $collength); + printf ("Column %02d: %-8s %s (%d chars)\n", $i, $coltypes{$coltype}, $col[$i-1], $collength); } }