config parser
am 17.10.2005 04:32:03 von Beast
To avoid hardcoding parameter in program, Im trying to make a separate
file for config.
However its not as simple as key/value which can be easily parse using
split.
It is something like group of parameter, ie:
group = marketing
recipient = user1@domain.tld
recipient = user2@domain.tld
subject = "Test mkt"
body = "this is a test msg for mkt"
group = accounting
recipient = user3@domain.tld
subject = "Test acc"
body = "this is a test msg for acct"
--
--beast
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
Re: config parser
am 17.10.2005 04:51:54 von Chris Devers
On Mon, 17 Oct 2005, Beast wrote:
> To avoid hardcoding parameter in program, Im trying to make a separate
> file for config. However its not as simple as key/value which can be
> easily parse using split.
Why not ? A crude split might fail, but splitting on / = / should work
for the format you describe.
But even that wheel doesn't need reinventing. The format your describe
isn't all that different from the old Windows .ini format:
[Marketing]
recipient=user1@domain.tld
recipient=user2@domain.tld
subject="Test mkt"
body="this is a test msg for mkt"
[Accounting]
recipient=user3@domain.tld
subject="Test acc"
body="this is a test msg for acct"
There's already a very good module to parse this format. You can write
your own, but you might as well just use Config::IniFiles:
http://search.cpan.org/~gcarls/Config-IniFiles/IniFiles.pm
You could make this as simple or as complex as you want, but a basic
script using this module should be very easy to implement.
A CPAN search for 'ini' turns up several similar modules, if this one
seems like overkill. Config::Abstract::Ini looks promising, as is
Config::IniHash, Config::Tiny, etc. There seem to be dozens...
--
Chris Devers
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
Re: config parser
am 17.10.2005 04:57:48 von krahnj
Beast wrote:
>
> To avoid hardcoding parameter in program, Im trying to make a separate
> file for config.
> However its not as simple as key/value which can be easily parse using
> split.
>
> It is something like group of parameter, ie:
>
> group = marketing
> recipient = user1@domain.tld
> recipient = user2@domain.tld
> subject = "Test mkt"
> body = "this is a test msg for mkt"
>
> group = accounting
> recipient = user3@domain.tld
> subject = "Test acc"
> body = "this is a test msg for acct"
http://search.cpan.org/search?query=config&mode=module
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
RE: config parser
am 17.10.2005 05:09:43 von cclarkson
Beast wrote:
: To avoid hardcoding parameter in program, Im trying to make a separate
: file for config.
: However its not as simple as key/value which can be easily parse using
: split.
:
: It is something like group of parameter, ie:
:
: group = marketing
: recipient = user1@domain.tld
: recipient = user2@domain.tld
: subject = "Test mkt"
: body = "this is a test msg for mkt"
:
: group = accounting
: recipient = user3@domain.tld
: subject = "Test acc"
: body = "this is a test msg for acct"
And how do you want data structure do you want it to go into?
An array of hashes, a hash of hash???
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org