Johan Vromans > OpenOffice-Wordlist-0.04 > OpenOffice::Wordlist



Annotate this POD

View/Report Bugs
Module Version: 0.04   Source  


OpenOffice::Wordlist - Read/write wordlists


This module allows reading and writing of wordlists (dictionaries).

For example:

  use OpenOffice::Wordlist;

  my $dict = OpenOffice::Wordlist->new;

  # Print all words.
  foreach my $word ( @{ $dict->words } ) {
      print $word, "\n";

  # Add some words.
  $dict->append( "openoffice", "great" );

  # Write a new dictionary.

When used as a program this module will read all dictionaries given on the command line and write the resultant list of words to standard output. For example,

  $ perl OpenOffice/ standard.dic


$dict = new( [ type => 'WDSWG6', language => 2057, neg => 0 ] )

Creates a new dict object.

Optional arguments:

type => 'WBSWG6' or 'WBSWG2' or 'WBSWG5'.

'WBSWG6' (default) indicates a UTF-8 encoded dictionary, the others indicate a ISO-8859.1 encoded dictionary.

language => code

The code for the language. I assume there's an extensive list of these codes somewhere. Some values determined experimentally:

    255   All
   1031   German (Germany)
   1036   French (France)
   1043   Dutch (Netherlands)
   2047   English UK
   2057   English USA

neg => 0 or 1

Whether the dictionary contains exceptions (neg = 1) or regular words (neg = 0).

If language and neg are not specified they are taken from the first file read, if any.

$dict->read( $file )

Reads the contents of the indicated file.

$dict->append( @words )

Append a list of words to the dictionary. To avoid unpleasant surprises, the words must be encoded in Perl's internal encoding.

The arguments may be constant strings or references to lists of strings.


Returns a reference to the list of words in the dictionary,

The words are encoded in Perl's internal encoding.

$dict->write( $file [ , $type ] )

Writes the contents of the object to a new dictionary.

Arguments: The name of the file to be written, and (optionally) the type of the file to be written (one of 'WBSWG6', 'WBSWG5', 'WBSWG2') overriding the type of the dictionary as establised at create time.


This example reads all dictionaries that are supplied on the command file, merges them, and writes a new dictionary.

  my $dict = OpenOffice::Wordlist->new( type => 'WBSWG6' );
  $dict->read( shift );
  foreach ( @ARGV ) {
    my $extra = OpenOffice::Wordlist->new->read($_);
    $dict->append( $extra->words );

Settings like the language and exceptions are copied from the file that is initially read.


Johan Vromans, <jv at>


There's currently no checking done on dictionary types arguments.

Please report any bugs or feature requests to bug-openoffice-wordlist at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc OpenOffice::Wordlist

You can also look for information at:



Copyright 2010 Johan Vromans, all rights reserved.


syntax highlighting: