in reply to Finding the right initialization-file module

YAML is what I would use for such a task. With a little OO help you can even do the "by name" function stuff:

use strict; use warnings; use YAML; my $yamlStr = <<YAML; --- flamencoArgs: spec: PAGE_HEADING: SABER Software Requirements Oct Release PAGE_TITLE: SABER Requirements topArgs: fileReadFn: eat_AvionicsFMEA hiliteCol: - 1 - 3 - 4 - 5 xtraTh: 1: colspan: 2 text: ' ' 3: colspan: 4 text: Front YAML my $stuff = bless YAML::Load($yamlStr); my $fn = $stuff->can ($stuff->{topArgs}{fileReadFn}); $fn->() if $fn; sub eat_AvionicsFMEA { print "Hey, how about that!\n"; }

Prints:

Hey, how about that!
True laziness is hard work

Replies are listed 'Best First'.
Re^2: Finding the right initialization-file module
by throop (Chaplain) on Dec 13, 2011 at 20:09 UTC
    Many thanks! That looks like just the ticket.

      Of course given that $stuff is an object we can squeeze a little more juice out:

      ... $stuff->header(); $fn->($stuff) if $fn; sub header { my ($self) = @_; print <<HEADER; $self->{flamencoArgs}{spec}{PAGE_HEADING} $self->{flamencoArgs}{spec}{PAGE_TITLE} HEADER } sub eat_AvionicsFMEA { my ($self) = @_; print "hiliteCols are: @{$self->{topArgs}{hiliteCol}}\n"; }

      Prints:

      SABER Software Requirements Oct Release SABER Requirements hiliteCols are: 1 3 4 5
      True laziness is hard work