Sanko Robinson > FLTK > FLTK::Preferences



Annotate this POD


View/Report Bugs
Module Version: 0.532006   Source  


FLTK::Preferences - Application preferences

Description ^

Preferences are data trees containing a root, branches and leaves.

Functions ^


my $gone = $preferences->deleteEntry( $entry );

Delete a group.


my $removed = $preferences->deleteGroup( $group );

Delete a group.


$preferences->destroy( );

Destroy individual keys.

Destroying the base preferences will flush changes to the prefs file. After destroying the base, none of the depending preferences must be read or written.


my $count = $preferences->entries( );

Returns the number of entries (key/value) pairs for a group.


my $key = $preferences->entry( $index );

Returns the name of an entry. There is no guaranteed order of entry names and $index must be within the range given by entries().


my $exists = $preferences->entryExists( $entry );

Returns 1, if a group with this name exists.


$preferences->flush( );

Writes all preferences to disk. This method works only with the base preference group.

Note: This method is rarely used as the preferences flush automatically when destroy( ) is called or when the base preferences go out of scope.


my $value = $preferences->get( $key, $value, $defaultValue );

Get an entry (key/value) pair.


my $path = $preferences->getUserdataPath( );

Creates a path that is related to the preferences file and that is usable for application data beyond what is covered by Preferences.


my $name = $preferences->group( $index );

Returns the group name of the $indexth group. There is no guaranteed order of group names and $index must be within the range given by groups( ).


my $exists = $preferences->groupExists( $group );

Returns 1, if a group with this name exists.


my $count = $preferences->groups( );

Returns the number of groups that are contained within a group.


my $tree = $preferences->new( $root, $vendor, $application );

Creates a new preferences object.

  • $root is a value representing either per machine (FLTK::Preferences::SYSTEM) or per user (FLTK::Preferences::USER) settings.
  • vendor is the unique identification of the author or vendor of $application.

    Note: vendor must be a valid directory name.

  • $application is a vendor unique application name, for example, PreferencesTest. Multiple preferences files can be created per application.

    Note: application name must be a valid file name.

my $node = $preferences->new( $parent, $group );

Creates a Preferences node in relation to a parent node for reading and writing

  • $parent is the base name for the group.
  • $group is a group name which may contain / separated group names.


  my $colors = FLTK::Preferences->new( $prefs, 'setup/colors' );
my $prefs = $preferences->new( $path, $vendor, $application );

Creates a Preferences object.

  • $path is an application-supplied path.


my $okay = $preferences->set( $entry, $value );

Set an entry (key/value) pair.


my $length = $preferences->size( $key );

Returns the size of the value part of an entry.

Author ^

Sanko Robinson <> -

License and Legal ^

Copyright (C) 2008-2010 by Sanko Robinson <>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.

syntax highlighting: