NAME

parse_subst - a Perl module to parse epics substitution-files

SYNOPSIS

use parse_subst;
undef $/;

my $st= <>;

my $r_templates= parse_subst::parse($st);
parse_subst::dump($r_templates);

DESCRIPTION

Preface

This module contains a parser function for epics substitution-files. The contents of the db-file are returned in a perl hash-structure that can then be used for further evaluation.

Implemented Functions:

data structures

In all the examples below, this is the substitution data parsed:

file adimogbl.template
  {
    {
      GBASE="U3IV:",
      TRIG1="U3IV:AdiMoVGblTrg.PROC",
    }
  }
file adimovhgbl.template
  {
    {
      GBASE="U3IV:",
      DRV="V",
      AdiMopVer="9",
      TRIG1="U3IV:AdiVGblPvr.PROC",
    }
    {
      GBASE="U3IV:",
      DRV="H",
      AdiMopVer="9",
      TRIG1="U3IV:AdiHGblPvr.PROC",
    }
  }

hash-structure

When the <mode> parameter of the parse function is not defined or set to 'templateHash', the parse function returns a hash structure.

Each template-name is a key in the template-hash. It is a reference to an array that contains the data for that template.

The array contains a reference to a hash for each instantiation of that template.

Each instantiation hash contains a key for each field name that gives the value of that field. Note that undefined fields-values are empty strings (""), not the perl undef-value.

Example of a hash that parse() returns:

$r_h= { 
        'adimovhgbl.template' => [
                                   {
                                     'TRIG1' => 'U3IV:AdiVGblPvr.PROC',
                                     'DRV' => 'V',
                                     'GBASE' => 'U3IV:',
                                     'AdiMopVer' => '9'
                                   },
                                   {
                                     'TRIG1' => 'U3IV:AdiHGblPvr.PROC',
                                     'DRV' => 'H',
                                     'GBASE' => 'U3IV:',
                                     'AdiMopVer' => '9'
                                   }
                                 ],
        'adimogbl.template' => [
                                 {
                                   'TRIG1' => 'U3IV:AdiMoVGblTrg.PROC',
                                   'GBASE' => 'U3IV:'
                                 }
                               ]
      };

list-structure

When the <mode> parameter of the parse function is set to 'templateList', the parse function returns a list containing the data.

Here is an example:

$r_h= [ 
        [
          'adimogbl.template',
          {
            'TRIG1' => 'U3IV:AdiMoVGblTrg.PROC',
            'GBASE' => 'U3IV:'
          }
        ],
        [
          'adimovhgbl.template',
          {
            'TRIG1' => 'U3IV:AdiVGblPvr.PROC',
            'DRV' => 'V',
            'GBASE' => 'U3IV:',
            'AdiMopVer' => '9'
          },
          {
            'TRIG1' => 'U3IV:AdiHGblPvr.PROC',
            'DRV' => 'H',
            'GBASE' => 'U3IV:',
            'AdiMopVer' => '9'
          }
        ]
      ];

old deprecated data structure

Version 1.0 of the parser used a hash instead of the array as explained above, with keys from "0" to .. "n". If you want a template-hash structure that is still compatible to this, set $old_parser to 1 like this:

$parse_subst::old_parser=1;

This format should no longer be used, however here is an example of the generated output:

$r_h= { 
        'adimovhgbl.template' => {
                                   '1' => {
                                            'TRIG1' => 'U3IV:AdiHGblPvr.PROC',
                                            'DRV' => 'H',
                                            'GBASE' => 'U3IV:',
                                            'AdiMopVer' => '9'
                                          },
                                   '0' => {
                                            'TRIG1' => 'U3IV:AdiVGblPvr.PROC',
                                            'DRV' => 'V',
                                            'GBASE' => 'U3IV:',
                                            'AdiMopVer' => '9'
                                          }
                                 },
        'adimogbl.template' => {
                                 '0' => {
                                          'TRIG1' => 'U3IV:AdiMoVGblTrg.PROC',
                                          'GBASE' => 'U3IV:'
                                        }
                               }
      };

AUTHOR

Goetz Pfeiffer, Goetz.Pfeiffer@helmholtz-berlin.de

SEE ALSO

perl-documentation