Thread Bestimmte Variablen auslagern in eine Datei (6 answers)
Opened by leissi at 2007-03-22 15:56

bloonix
 2007-03-23 10:47
#75264 #75264
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
[quote=Froschpopo,22.03.2007, 23:01]
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
open CONFIG, "main.cfg" or die $!;
while (<CONFIG>) {
  chomp;
  s/\/\*.*//;
  s/^\s+//;
  s/\s+$//;
  next unless length;
  my ($key, $value) = split(/\s*=\s*, $_, 2);
  $config{$key} = $value;
}

#main cfg
Name = Froschpopo
[/quote]
Das ist unbrauchbar!

1. Syntaxfehler bei split()
2. Kommentare werden nicht richitg behandelt
3. Keine Sektionen, Strukturen moeglich
4. CONFIG wird nicht geschlossen

use CPAN::Modules; !

main.cfg

# comment
name = froschpopo # comment

$VAR1 = {
         '# comment' => undef,
         'name' => 'froschpopo # comment'
       };
\n\n

<!--EDIT|opi|1174640269-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.

View full thread Bestimmte Variablen auslagern in eine Datei