Thread lokale Variable aus Sub ins Hauptprogramm! (30 answers)
Opened by skontox at 2003-09-24 21:07

pq
 2005-11-22 22:26
#55927 #55927
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
[quote=pq,20.11.2005, 19:05]globale variablen sind nicht generell schlecht, aber man sollte sie vermeiden.
ich mache gerne sowas:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
package MyConf;
use strict;
use warnings;
use vars qw($Conf @EXPORT_OK);
use base 'Exporter';
@EXPORT_OK = qw($Conf);

# erstelle $Conf
...

#script:
use MyConf '$Conf';
# mach was mit $Conf
[/quote]
ich schrieb ja schon ein beispiel.
den code mit "package MyConf" musst du in eine datei MyConf.pm packen.
und vielleicht mal perldoc perlmod lesen.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem

View full thread lokale Variable aus Sub ins Hauptprogramm!