Leser: 2
|< 1 2 >| | 13 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
#!/usr/bin/perl -w
use strict;
use foo;
our $test = "test";
print "main:: $test";
&foo::out();
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/perl -w
use strict;
our $test = "teast";
print "main:: $test\n";
&foo::out();
package foo;
sub out {print __PACKAGE__ . ":: $test\n"};
1;
1
2
3
4
5
6
7
8
9
#directorys
root_dir=G:/programmierung/perl/ager
data_dir=data/
images_dir=images/
#design & style
button_color=
[...]
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;
}
1
2
3
4
5
6
7
8
9
10
package GUI;
use strict;
sub start {
use Depot::manipulate;
our %config = ();
&manipulate::load_config();
}
1;
1
2
3
4
5
6
7
8
9
10
11
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.
1
2
3
4
5
6
package Foo;
use strict;
use base qw(Exporter);
our @EXPORT_OK = qw($test);
our $test = 7;
1
1
2
3
4
5
6
7
8
9
package GUI;
use strict;
use diagnostics;
[...]
use base qw(Exporter);
our @EXPORT_OK = qw(%config);
[...]
our %config = ();
&manipulate::load_config();
1
2
3
4
5
6
7
8
package manipulate;
use strict;
use Depot::GUI;
[...]
if ($var eq "$option") {
$config{$var} = $value if $value;
last;
}
|< 1 2 >| | 13 Einträge, 2 Seiten |