#!/usr/bin/perl -w
use strict;
use XML::Simple;
use Data::Dumper;
### BEGINNING STRUCTURE
my %t_type = (
'a' => {
one => {low => 1000, high => 3000, percent => 25},
two => {low => 200,high => 2000, percent => 30},
three => {low => 1000,high => 6000, percent => 40},
four => {low => 300,high => 1800, percent => 35},
five => {low => 10, high => 40, percent => 60},
six => {low => 2, high => 12, percent => 50},
seven => [
{select => 'small',low => 3,high => 3,percent => 30},
],
},
'b' => {
one => {low => 1000, high => 3000, percent => 25},
two => {low => 200,high => 2000, percent => 30},
three => {low => 1000,high => 6000, percent => 40},
four => {low => 300,high => 1800, percent => 35},
five => {low => 10, high => 40, percent => 60},
six => {low => 2, high => 12, percent => 50},
seven => [
{select => 'medium',low => 1,high => 1,percent => 10},
{select => 'large',low => 1,high => 1,percent => 10},
],
},
);
print "\t BEFORE\n";
print "data...\n";
print "$t_type{'b'}{'seven'}[0]->{'select'} \n";
foreach my $item ( @{$t_type{b}{seven}} ) {
print "... $item->{'select'}\n";
}
print "\n\t AFTER\n";
print "creating file...\n";
my $xsimple = XML::Simple->new();
open(L, ">tt.xml");
print L $xsimple->XMLout(\%t_type,
noattr => 1,
xmldecl => '',
GroupTags => { 'seven' => 'select' }
);
close(L);
print "reading file...\n";
%t_type = ();
my $t_type = XMLin('tt.xml',GroupTags => { 'seven' => 'select' });
%t_type = \$t_type;
####
### lets test that returned structure
# yep its the same. must be a referrence problem?
print "dumping structure...\n";
print Dumper($t_type);
####
print "data...\n";
print "$t_type{'b'}{'seven'}[0]->{'select'} \n";
foreach my $item ( @{$t_type{b}{seven}} ) {
print "... $item->{'select'}\n";
}