View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Peter Karman > SWISH-Prog > SWISH::Prog::Config



Annotate this POD



Open  0
View/Report Bugs
Module Version: 0.75   Source  


SWISH::Prog::Config - read/write Swish-e config files


 use SWISH::Prog::Config;
 my $config = SWISH::Prog::Config->new;


The SWISH::Prog::Config class is intended to be accessed via SWISH::Prog->new().

See the Swish-e documentation for a list of configuration parameters. Each parameter has an accessor/mutator method as part of the Config object. Some preliminary compatability is offered for SWISH::3::Config with XML format config files.

NOTE: Every config parameter can take either a scalar or an array ref as a value. In addition, you may append config values to any existing values by passing an additional true argument. The return value of any 'get' is always an array ref.


 $config->MetaNameAlias( ['foo bar', 'one two', 'red yellow'] );
 $config->MetaNameAlias( 'green blue', 1 );
 print join("\n", @{ $config->MetaNameAlias }), " \n";
 # would print:
 # foo bar
 # one two
 # red yellow
 # green blue


new( params )

Instantiate a new Config object. Takes a hash of key/value pairs, where each key may be a Swish-e configuration parameter.


 my $config = SWISH::Prog::Config->new( DefaultContents => 'HTML*' );
 print "DefaultContents is ", $config->DefaultContents, "\n";


Get/set the debug level. Default is 0.


Get/set flags affecting the verbosity of the program.


Class method.

Returns array ref of all the option (method) names supported.

read2( path/file )

Reads version 2 compatible config file and stores in current object. Returns parsed config file as a hashref or undef on failure to parse.


 use SWISH::Prog::Config;
 my $config = SWISH::Prog::Config->new();
 my $parsed = $config->read2( 'my/file.cfg' );
 # should print same thing
 print $config->WordCharacters->[0], "\n";
 print $parsed->{WordCharacters}, "\n";

write2( path/file [,prog_mode] )

Writes version 2 compatible config file.

If path/file is omitted, a temp file will be written using File::Temp.

If prog_mode is true all config directives inappropriate for the -S prog mode in the Native::Indexer are skipped. The default is false.

Returns full path to file.

Full path is also available via file() method.


Returns name of the file written by write2().

write3( path/file )

Write config object to file in SWISH::3::Config XML format.


Returns current Config object as a hash ref.


Returns array ref of all MetaNames, regardless of whether they are declared as MetaNames, MetaNamesRank or MetaNameAlias config options.


Returns object as version 2 formatted scalar.

If prog_mode is true skips inappropriate directives for running the Native::Indexer. Default is false. See write2().

This method is used to overload the object for printing, so these are equivalent:

 print $config->stringify;
 print $config;

ver2_to_ver3( file )

Utility method for converting Swish-e version 2 style config files to SWISH::3::Config XML style.

Converts file to XML format and returns as XML string.

  my $xmlconf = $config->ver2_to_ver3( 'my/file.config' );

If file is omitted, uses the current values in the calling object.

get_stemmer_lang([ fuzzymode ])

Returns the 2-letter language code for the Snowball stemmer corresponding to fuzzymode. If fuzzymode is not defined, calls FuzzyIndexingMode() method on the config object.


IgnoreTotalWordCountWhenRanking defaults to 0 which is not the default in Swish-e. This is to make the RankScheme feature work by default. Really, the default should be 0 in Swish-e itself.


Peter Karman, <>


Please report any bugs or feature requests to bug-swish-prog 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 SWISH::Prog

You can also look for information at:


Copyright 2006-2009 by Peter Karman

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


syntax highlighting: