Params.pm - Parameter file parser |
use Params; my($rh_parameter); my($obj) = new Params("parameter_file_name"); $rh_parameter = $obj->GetData("type_name");
Get data from text file. This is as a common parser of data file. You can get specified type data. And you can define any type names.
That data will be got after pre-process. Pre-processor directives are defined following...
#define, #undef, #if, #elseif, #endif, #include
$filename
specify a file name of data.
The \@identifier
specify a reference of array that is for keep pre-processed data.
If you omit a reference of array, pre-processed data will be kept in this instance.
$obj->PreProcess("data.txt", \@buffer);
$typename
specify type name of your wanted data.
The \@identifier
specify reference of array that is for keys of data.
The \%data
specify reference of hash that is for data.
$obj->GetData("type", \%data, \@identifier, \@buffer);
If first character of each lines is `#' and no match to directive, it will be handled as comment. If end character of each lines is `\', it continue next line. Each data define is contain one data type, one identifier and one data list. Data type and identifier is delimited by spaces. Block of data list is start with `{' and terminated with ``};''. Each data line is terminated with `;' and must be only one line.
#comments type identifier{ data-list; ... ; ... ; };
{ nospace-character character-sequence nospace-character; ... ; ... ; };
#define identifier #define identifier token string
Pre-processor will replace `%identifier%' that defined by #define directive. But, it exclude comment line and replace only already defined value. Replace process is only onetime this mean can not nest define. If pre-processor can not find in define, it will search in environment variable. The identifier can include alphabet, digit number and under score.
#undef identifier
#if expression strings #elseif expression strings #else strings #endif
In expression you can use the `defined' function.
defined(identifier)
This expression is true, if identifier is defined with #define directive or environment variable.
#include file name
Tetsuya Shigetome, <t_shigetome@muf.biglobe.ne.jp>.
First release of Perl module version.
Params.pm - Parameter file parser |