use Glib; $data .= $_ while (<DATA>); $f = Glib::KeyFile->new; $f->load_from_data($data); if ($f->has_group('Main') && $f->has_key('Main', 'someotherkey')) { $val = $f->get_integer('Main', 'someotherkey'); print $val . "\n"; } 0; __DATA__ # a comment [MainSection] somekey=somevalue someotherkey=42 someboolkey=true listkey=1;1;2;3;5;8;13;21 localekey=Good Morning localekey[it]=Buon giorno localekey[es]=Buenas dias localekey[fr]=Bonjour
The syntax of key files is described in detail in the Desktop Entry Specification, here is a quick summary: Key files consists of groups of key-value pairs, interspersed with comments.
Retrieves a boolean value from $key inside $group_name.
May croak with a Glib::Error in $@ on failure.
Retrieves a list of booleans from $key inside $group_name.
May croak with a Glib::Error in $@ on failure.
Sets a list of booleans in $key inside $group_name. If $key cannot be found then it is created. If $group_name cannot be found then it is created.
Sets a boolean value to $key inside $group_name. If $key is not found, it is created.
Retreives a comment above $key from $group_name. If $key is undef then $comment will be read from above $group_name. If both $key and $group_name are undef, then $comment will be read from above the first group in the file.
May croak with a Glib::Error in $@ on failure.
Places a comment above $key from $group_name. If $key is undef then $comment will be written above $group_name. If both $key and $group_name are undef, then $comment will be written above the first group in the file.
May croak with a Glib::Error in $@ on failure.
Retrieves a double value from $key inside $group_name.
May croak with a Glib::Error in $@ on failure.
Retrieves a list of doubles from $key inside $group_name.
May croak with a Glib::Error in $@ on failure.
Sets a list of doubles in $key inside $group_name. If $key cannot be found then it is created. If $group_name cannot be found then it is created.
Sets a double value to $key inside $group_name. If $key is not found, it is created.
Checks whether $group_name is present in $key_file.
Checks whether $group_name has $key in it.
May croak with a Glib::Error in $@ on failure.
Retrieves an integer value from $key inside $group_name.
May croak with a Glib::Error in $@ on failure.
Retrieves a list of integers from $key inside $group_name.
May croak with a Glib::Error in $@ on failure.
Sets a list of doubles in $key inside $group_name. If $key cannot be found then it is created. If $group_name cannot be found then it is created.
Sets an integer value to $key inside $group_name. If $key is not found, it is created.
Returns the list of keys inside a group of the key file.
May croak with a Glib::Error in $@ on failure.
Sets the list separator character.
Parses a string containing a key file structure.
May croak with a Glib::Error in $@ on failure.
Parses a key file, searching for it inside the data directories. In scalar context, it returns a boolean value (true on success, false otherwise); in array context, it returns a boolean value and the full path of the file.
May croak with a Glib::Error in $@ on failure.
Parses a key file, searching for it inside the specified directories. In scalar context, it returns a boolean value (true on success, false otherwise); in array context, it returns a boolean value and the full path of the file.
May croak with a Glib::Error in $@ on failure.
Parses a key file.
May croak with a Glib::Error in $@ on failure.
Returns the value associated with $key under $group_name translated in the given $locale if available. If $locale is undef then the current locale is assumed.
May croak with a Glib::Error in $@ on failure.
May croak with a Glib::Error in $@ on failure.
Associates a list of string values for $key and $locale under $group_name. If the translation for $key cannot be found then it is created.
Removes a comment from a group in a key file. If $key is undef, the comment will be removed from above $group_name. If both $key and $group_name are undef, the comment will be removed from the top of the key file.
May croak with a Glib::Error in $@ on failure.
Removes a group from a key file.
May croak with a Glib::Error in $@ on failure.
Removes a key from $group_name.
May croak with a Glib::Error in $@ on failure.
Retrieves a string value from $key inside $group_name.
May croak with a Glib::Error in $@ on failure.
Retrieves a list of strings from $key inside $group_name.
May croak with a Glib::Error in $@ on failure.
Sets a list of strings in $key inside $group_name. The strings will be escaped if contain special characters. If $key cannot be found then it is created. If $group_name cannot be found then it is created.
Sets a string value to $key inside $group_name. The string will be escaped if it contains special characters. If $key is not found, it is created.
May croak with a Glib::Error in $@ on failure.
Retrieves the literal value of $key inside $group_name.
May croak with a Glib::Error in $@ on failure.
Sets the literal value of $key inside $group_name. If $key cannot be found, it is created. If $group_name cannot be found, it is created.
This software is licensed under the LGPL. See Glib for a full notice.