Also bei mir klappts nich..
Ich erklaer mal etwas genauer, ich will aus einer Datei die foglendes Format hat einen Hash befuellen:
#directorys
root_dir=G:/programmierung/perl/ager
data_dir=data/
images_dir=images/
#design & style
button_color=
[...]
Das habe ich wie folgt geloest (manipulate.pm):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
sub load_config {
my @args = qw/root_dir data_dir images_dir button_color alternatecolor_first alternatecolor_second marked_color/;
open(CONF, "<depot_conf.conf") or die("Can't open depot_conf.conf: $!");
for (<CONF>) {
next if ( (/^#/) || (/^\W/) ); #ignore comments
chomp;
my @parts = split(/=/, $_);
my ($var, $value) = @parts;
for my $option ($#args) {
if ($var eq "$option") {
__GUI__ $config{$var} = $value;
last;
}
print "$var:" . __PACKAGE__ . "$config{$var}\n";
}
}
close CONF;
}
Das ganze wird von GUI.pm aus aufgerufen:
package GUI;
use strict;
sub start {
use Depot::manipulate;
our %config = ();
&manipulate::load_config();
}
1;
Leider erhalte ich ich die Fehlermedlung:
G:\programmierung\perl\lager>perl lager.txt
Global symbol "%config" requires explicit package name at Depot/manipulate.pm li
ne 16.
syntax error at Depot/manipulate.pm line 16, near "$config{"
Global symbol "%config" requires explicit package name at Depot/manipulate.pm li
ne 19.
syntax error at Depot/manipulate.pm line 23, near "}"
Compilation failed in require at Depot/GUI.pm line 5.
BEGIN failed--compilation aborted at Depot/GUI.pm line 5.
Compilation failed in require at lager.txt line 6.
BEGIN failed--compilation aborted at lager.txt line 6.
Vielen Dank :)
MfG
Pörl.