Thread XML::Simple Problem (in Hash fehlt Root-Element) (8 answers)
Opened by FlorianL at 2012-03-06 14:54

Mindfoo
 2012-03-07 18:43
#156684 #156684
User since
2009-04-03
10 Artikel
BenutzerIn
[default_avatar]
da bin ich wieder... (mir ist eingefallen das ich schon nen account bei euch hatte :))

also, der ganze xml::simple quatsch war mir zu mühsam, ich geh jetzt einfach das config file mit nem regex durch :P

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
sub confighandler {
        chomp(my $cmd = shift);
        chomp(my $option = shift);
        chomp(my $value = shift);
        open CONFIG, "<","aircracker.conf" or die $!;
        my @cfgdata = <CONFIG>;
        close(CONFIG);
        if (($cmd eq 'read') && ($option)) {
                foreach (@cfgdata) {
                        if ($_ =~ m/<$option>(.+)<\/$option>/) {
                                return $1;
                        }
                }
                return ("Error: not an option: $option");
        } elsif (($cmd eq 'write') && ($option) && ($value)) {
                my @newcfg;
                foreach (@cfgdata) {
                        $_ =~ s/<$option>.+<\/$option>/<$option>$value<\/$option>/;
                        push(@newcfg, $_);
                }
                open NEWCONFIG, ">","aircracker.conf" or die $!;
                print NEWCONFIG @newcfg;
                close(NEWCONFIG);
                return ("Config saved");
        } else {
                return ("Error: read or write?");
        }
}

confighandler("write","daemon","2");

Last edited: 2012-03-07 18:44:49 +0100 (CET)

View full thread XML::Simple Problem (in Hash fehlt Root-Element)