#!/usr/bin/perl -w
use strict;
use warnings;
use CGI;
use Data::Dumper;
use XML::Simple;
my $cgi = new CGI( { a => 1, b=> 2, source => 3 } );
my $elements = $cgi->Vars();
DOIT();
$elements = {
'source' => {
'a' => '1',
'b' => '2',
}
};
DOIT();
$elements = {
'butterscotch' => {
'a' => '1',
'b' => '2',
},
'content' => "Look at me Maa, I'm eating buttterscotch",
};
DOIT();
sub DOIT {
my $xs = new XML::Simple();
my $xml = $xs->XMLout(
$elements,
rootname => 'source'
);
print Dumper $elements;
print $xml;
print '='x60,"\n";
}
__END__
$VAR1 = {
'a' => '1',
'b' => '2',
'source' => '3'
};
============================================================
$VAR1 = {
'source' => {
'a' => '1',
'b' => '2'
}
};
============================================================
$VAR1 = {
'butterscotch' => {
'a' => '1',
'b' => '2'
},
'content' => 'Look at me Maa, I\'m eating buttterscotch'
};
Look at me Maa, I'm eating buttterscotch
============================================================