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

guest FlorianL
 2012-03-07 14:26
#156677 #156677
dank euch! hat mir geholfen :)

nächste frage: ich möchte nun da ich die xml lesen kann auch wieder einzelne werte speichern lassen, allerdings ist mir die XMLout() funktion nicht ganz klar...

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use XML::Simple;
my $cfg = XMLin('aircracker.conf', KeepRoot => 1);

sub cfghandler {
        my $cmd = shift;
        my $option = shift;
        my $value = shift;
        my $xml;
        if (($cmd eq 'read') && ($option) && (!$value)) {
        } elsif (($cmd eq 'write') && ($option) && ($value)) {
                if ($option eq 'daemon') {
                        $xml = { 'system' => { 'daemon' => "$value" } };
                        print XMLout( { config => $xml }, AttrIndent => 1, KeepRoot => 1, NoAttr => 1, OutputFile => $cfg );
                }

Code (perl): (dl )
cfghandler("write","daemon","test");


Quote
Can't call method "print" on unblessed reference at /usr/share/perl5/XML/Simple.pm line 634.

Last edited: 2012-03-07 14:35:38 +0100 (CET)

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