Check out Config::General. Here is an example using snippets of your config file:
use strict; use Config::General; my $conf = new Config::General('bar.conf'); my %config = $conf->getall; use Data::Dumper; print Dumper \%config;
and the configuration file 'bar.conf':
<define> destination = /u90/gvc_archive/new runonce = port100 </define> <macro arbor_ama> regex = /F.*?-P.*?\.(\d+)\.ama/ dfield = $1 </macro> <macro dex> regex = /^P.*?_DSC_.*?\.(\d+)\.ama$/ dfield = $1 </macro> <rule 10> port = port11,port41, port61,port77,port85 regex = dfield = NULL macro = rtcd_everything </rule> <rule 60> port = 87 regex = /F.*?\-P.*?_FCC_(\d+)_.*?\.cdr/ dfield = $1 macro = usl1 macro = usl2 </rule>
Which produces the following output:
$VAR1 = {
  'define' => {
    'runonce' => 'port100',
    'destination' => '/u90/gvc_archive/new'
  },
  'macro' => {
    'dex' => {
      'dfield' => '$1',
      'regex' => '/^P.*?_DSC_.*?\\.(\\d+)\\.ama$/'
    },
    'arbor_ama' => {
      'dfield' => '$1',
      'regex' => '/F.*?-P.*?\\.(\\d+)\\.ama/'
    }
  },
  'rule' => {
    '10' => {
      'dfield' => 'NULL',
      'macro' => 'rtcd_everything',
      'port' => 'port11,port41, port61,port77,port85',
      'regex' => ''
    },
    '60' => {
      'dfield' => '$1',
      'macro' => [
        'usl1',
        'usl2'
      ],
      'port' => '87',
      'regex' => '/F.*?\\-P.*?_FCC_(\\d+)_.*?\\.cdr/'
    }
  }
};

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: Request For a lil Direction... by jeffa
in thread Advice sought for parsing config file by snafu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.