Ich hab mein Programm durch AppConfig und einer conf-File mit etwas mehr Komfort ausgestattet.
Der "AppConfig + .conf-File"-Part funktioniert auch wunderbar, die Probleme hab ich mit den CmdlineOptions,
die Argumente der Art ARGCOUNT_HASH funktionieren irgendwie nicht so wie sie sollen.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl
use strict;
use warnings;
use AppConfig;
my $config = new AppConfig;
$config->define("module|modules|m=s%" => { DEFAULT => 'off' });
$config->file(\*DATA) if @ARGV == 0;
$config->getopt('gnu_getopt');
my %modules = %{ $config->modules()};
print "# $_ = $modules{$_}\n" for keys %modules;
printf("Module: %s = %s\n", $_, $modules{$_})
for grep { defined $modules{$_} && lc $modules{$_} eq 'on' }
keys %modules;
_ _DATA_ _
# Configuration File
Module FTP = On
Module WWW = Off
Ohne Argumente soll der Programmlauf allein ueber die Konfigurationsdatei bestimmt werden.
# Ausgabe (ohne Argumente):
# FTP = On
# WWW = Off
Module: FTP = On
Rufe ich es jetzt aber wie folgt auf
% myapp --module 'WWW=On'
existiert dann zwar der Schluessel WWW im Modules-Hash ($config->modules()) aber ist auf undef gesetzt, statt auf on.
# Ausgabe:
Use of uninitialized value in concatenation (.) or string at myapp line 18.
# WWW =
Any ideas ?
Schon mal vielen Dank!
Grusz Christian.
,,Das perlt aber heute wieder...'' -- Dittsche