#!/usr/bin/perl -w use Parse::DMIDecode qw(); use Data::Dumper; use XML::Simple; use warnings; my $decoder = Parse::DMIDecode->new(nowarnings => 1); $decoder->probe; my $xml = new XML::Simple; my %xml_hash; for my $handle ($decoder->get_handles) { $xml_hash{$handle->handle}{"dmitype"} = $handle->dmitype; $xml_hash{$handle->handle}{"bytes"} = $handle->bytes; $xml_hash{$handle->handle}{"description"} = $handle->description; for my $keyword ($handle->keywords) { my $value = $handle->keyword($keyword); printf(" Keyword \"%s\" => \"%s\"\n", $keyword, (ref($value) eq 'ARRAY' ? join(', ',@{$value}) : ($value||'')) ); $xml_hash{$handle->handle}{"keywords"}{$keyword} = (ref($value) eq 'ARRAY' ? join(', ',@{$value}) : ($value||'')); } } #print Dumper(%xml_hash); my $xml_out = $xml->XMLout(%xml_hash,NoAttr => 1,RootName => 'dmidecode',); print $xml_out;