PDIC::Writer - A Perl module for creating PDIC file


NAME

PDIC::Writer - A Perl module for creating PDIC (.dic) file


SYNOPSIS

 use PDIC::Writer;

 # Create a PDIC file called 'sample.dic', which has 100 entries
 # and headwords with a length of 10 bytes on average.
 my $writer = new PDIC::Writer('sample.dic', 100, 10);

 $writer->prepare();

 my $entry = {
     headword => 'apple',
     pronunciation => '',
     definition => 'firm round fruit with a central core',
     example => 'An apple a day keeps a doctor away',
     level => 3,
     marked => 0,
     revised => 0,
 };

 $writer->add_entry($entry);

 $writer->finish();


DESCRIPTION

The PDIC::Writer module for creating a .dic file of PDIC, a Win32 electronic dictionary application developed by TaN <sgm00353@nifty.ne.jp>.


CONSTRUCTOR

new( FILENAME, NUM_ENTRIES, AVERAGE_HEADWORD_LENGTH)
FILENAME is the name of PDIC file to be created. NUM_ENTRIES is the number of dictionary entries. AVERAGE_HEADWORD_LENGTH is the average length of headwords.


METHODS

prepare
This method opens the .dic file and initializes it.

add_entry( ENTRY )
This method adds an entry to the dictionary. ENTRY is a hash ref, which has following keys: headword, pronunciation, definition, example, level, marked, revised.

headword, pronunciation, definition and example are strings. level is a number between 0 and 15. marked and revised are 0 or 1.

Entries are stored in a queue and are written down to the file periodically.

finish
This method writes down entries in the queue to the .dic file, updates the header and indices, and closes the .dic file.


COPYRIGHT

Copyright 2002 Tsutomu Kuroda.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 PDIC::Writer - A Perl module for creating PDIC file