I figured that it had to be a simple mistake---Ah!

$keyword, $decoder->keyword($keywords) );

solved the problem:

#!/usr/local/bin/perl use strict; use warnings; use Parse::DMIDecode; my $decoder = Parse::DMIDecode->new( dmidecode => "/usr/sbin/dmidecode", nowarnings => 1, ); $decoder->probe; my @keywords = $decoder->keywords; for my $keyword (@keywords) { printf("%s => %s\n", $keyword, $decoder->keyword($keyword) ); }
Update: It's been awhile since I used Parse::DMIDecode. I remembered that the "mistake" is not a mistake. In other words, what you are seeing is exactly what Parse::DMIDecode should be doing. You are entering "slot", but "slot" is not a keyword but a "type". A "keyword" is a "string". If you enter a type, dmidecode will return a list of all valid keywords, which is what is happening. For example, a keyword would be something like system-version, processor-manufacturer, etc. Dmidecode has a good man page. Be sure to check it out.

Update: Just a little script to look at the "slot" type:

#!/usr/bin/perl use strict; use warnings; use Parse::DMIDecode; my $decoder = Parse::DMIDecode->new( dmidecode => '/usr/sbin/dmidecode', nowarnings => 1, ); $decoder->probe; printf("System: %s => %s %s %s %s\n", $decoder->keyword("slot-current-usage"), $decoder->keyword("slot-designation"), $decoder->keyword("slot-id"), $decoder->keyword("slot-length"), $decoder->keyword("slot-type"), ); my $total_structures = $decoder->structures; printf("Structures: %s\n", $decoder->structures($total_structures), );

I added $decoder->structures($total_structures). It'll tell how many "types" there are. I got 40---numbered starting at 0 thru 39.


In reply to Re: parse dmidecode keywords by Khen1950fx
in thread parse dmidecode keywords by perldesire

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.