#!/usr/local/bin/perl # FILE %usr/unixonly/hp200lx/txt2ndb.pl # # convert text files into HP200LX NDB format # # The input files contain one or more records, each record # separated by a blank line. The first non-blank line of each # record is the title # # written: 1998-07-22 # latest update: 1998-07-23 19:09:19 # use HP200LX::DB ('openDB'); # configuration and setup $template_ndb= 'leer.ndb'; # already existing note database # use any, perferably empty, note database $template_title= 'Titel'; # field names of a German language HP200LX $template_note= 'Notiz'; # the note field $template_kat= 'Kategorie'; # category is not really used here ... $note= <) { chop; s/\015//g; if (/^$/) { $sec= ''; next; } if ($sec) { # append $rec->{Notiz} .= "$_\r\n"; } else { # The first non-blank line indicates the start of a section. # This line is used as the title. $sec= $_; $rec= { $template_title => $sec, $template_note => '', }; push (@tmp, $rec); } } close (FI); @tmp; } # ---------------------------------------------------------------------------- # open the existing template database and overwrite # any records therein with records from the text file sub write_ndb_database { my $fnm_db= shift; # output NDB file my ($ndb, @ndb); # HP 200 LX Notes Database object and array tie my $ndb= openDB ($template_ndb); # The input database must exist!! tie (@ndb, HP200LX::DB, $ndb); my $num= 0; foreach $rec (@_) { # NOTE: Perl can not push to tied arrays (yet). # We have to count the records. $ndb[$num++]= $rec; } # finally: save the database to the disc file $ndb->saveDB ($fnm_db); }