Thread Klassendaten: Globale Variablen in Klassen (16 answers)
Opened by Gast at 2004-04-17 13:01

Strat
 2004-04-19 02:07
#81629 #81629
User since
2003-08-04
5246 Artikel
ModeratorIn
[Homepage] [default_avatar]
was haelst du von der Idee, die Konfiguration in einen Hash zu packen? Dann hast du nur eine globale Variable, die du z.B. in eine Subroutine auslagern koenntest, z.B.
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
package MyProgram::Config;
use FindBin;
sub GetConfig {
  return {
    pathToScript => $FindBin::Bin,
    xyz => 30,
    # ...
  };
} # GetConfig

und im Hauptprogramm:
Code (perl): (dl )
1
2
3
4
5
6
7
#! /usr/bin/perl
use warnings;
use strict;
use FindBin;
use lib $FindBin::Bin;
use MyProgram::Config;
my $configHashRef = MyProgram::Config->GetConfig();

oder aehnlich
perl -le "s::*erlco'unaty.'.dk':e,y;*kn:ai;penmic;;print"
http://www.fabiani.net/

View full thread Klassendaten: Globale Variablen in Klassen