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 31 32 33 34 35 36 37 38 39 40 41 42 43
#!/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;