1Parse::DMIDecode::ExampUlseesr(3Cpomn)tributed Perl DocuPmaernstea:t:iDoMnIDecode::Examples(3pm)
2
3
4

NAME

6       Parse::DMIDecode::Examples - Examples using Parse::DMIDecode::Examples
7

EXAMPLES

9   Example 1: Find the Number of Physical CPUs
10        use strict;
11        use Parse::DMIDecode qw();
12
13        my $dmi = Parse::DMIDecode->new( nowarnings => 1 );
14        $dmi->probe;
15
16        my $physical_cpus = 0;
17        for my $handle ($dmi->get_handles(group => "processor")) {
18            my $type = ($handle->keyword("processor-type") or "");
19            next unless $type =~ /Central Processor/i;
20
21            # Check the status of the cpu
22            my $status = ($handle->keyword("processor-status") or "");
23            if ($status !~ /Unpopulated/i) {
24                $physical_cpus++;
25            }
26        }
27
28        printf("There %s %d physical %s in this machine.\n",
29                ($physical_cpus == 1 ? "is" : "are"),
30                $physical_cpus,
31                ($physical_cpus == 1 ? "CPU" : "CPUs"),
32            );
33
35       Copyright 2007 Nicola Worthington.
36
37       This software is licensed under The Apache Software License, Version
38       2.0.
39
40       <http://www.apache.org/licenses/LICENSE-2.0>
41
42
43
44perl v5.38.0                      2023-07-21   Parse::DMIDecode::Examples(3pm)
Impressum