++ed by:
2 non-PAUSE users
Author image H.Merijn Brand
and 1 contributors


System::Info - Factory for system specific information objects


    use System::Info;

    my $si = System::Info->new;

    printf "Hostname:              %s\n", $si->host;
    printf "Number of CPU's:       %s\n", $si->ncpu;
    printf "Processor type:        %s\n", $si->cpu_type; # short
    printf "Processor description: %s\n", $si->cpu;      # long
    printf "OS and version:        %s\n", $si->os;


    use System::Info qw( sysinfo );
    printf "[%s]\n", sysinfo ();


    $ perl -MSystem::Info=si_uname -le print+si_uname


System::Info tries to present system-related information, like number of CPU's, architecture, OS and release related information in a system-independent way. This releases the user of this module of the need to know if the information comes from Windows, Linux, HP-UX, AIX, Solaris, Irix, or VMS, and if the architecture is i386, x64, pa-risc2, or arm.



Factory method, with fallback to the information in POSIX::uname ().


sysinfo returns a string with host, os and cpu_type.


sysinfo_hash returns a hash reference with basic system information, like:

  { cpu       => 'Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz (GenuineIntel 2700MHz)',
    cpu_count => '1 [8 cores]',
    cpu_cores => 8,
    cpu_type  => 'x86_64',
    distro    => 'openSUSE Tumbleweed 20171030',
    hostname  => 'foobar',
    os        => 'linux - 4.13.10-1-default [openSUSE Tumbleweed 20171030]',
    osname    => 'Linux',
    osvers    => '4.13.10-1-default'

si_uname (@args)

This class gathers most of the uname(1) info, make a comparable version. Takes almost the same arguments:

    a for all (can be omitted)
    n for nodename
    s for os name and version
    m for cpu name
    c for cpu count
    p for cpu_type


There are more modules that provide system and/or architectural information.

Where System::Info aims at returning the information that is useful for bug reports, some other modules focus on a single aspect (possibly with way more variables and methods than System::Info does supports), or are limited to use on a specific architecture, like Windows or Linux.

Here are some of the alternatives and how to replace that code with what System::Info offers. Not all returned values will be exactly the same.


 use Sys::Hostname;
 say "Hostname: ", hostname;


 use System::Info;
 my $si = System::Info->new;
 say "Hostname: ", $si->host;

Sys::Hostname is a CORE module, and will always be available.


 use Unix::Processors;
 my $up = Unix::Processors->new;
 say "CPU type : ", $up->processors->[0]->type;
 say "CPU count: ", $up->max_physical;
 say "CPU cores: ", $up->max_online;
 say "CPU speed: ", $up->max_clock;


 use System::Info;
 my $si = System::Info->new;
 say "CPU type : ", $si->cpu;
 say "CPU count: ", $si->ncpu;
 say "CPU cores: ", $si->ncore;
 say "CPU speed: ", $si->cpu =~ s{^.*\b([0-9.]+)\s*[A-Z]Hz.*}{$1}r;

The number reported by max_physical is inaccurate for modern CPU's


Sys::Info has a somewhat rigid configuration, which causes it to fail installation on e.g. (modern versions of) CentOS and openSUSE Tumbleweed.

It aims at returning a complete set of information, but as I cannot install it on openSUSE Tumbleweed, I cannot test it and show the analogies.


 use Sys::CPU;
 say "CPU type : ", Sys::CPU::cpu_type  ();
 say "CPU count: ", Sys::CPU::cpu_count ();
 say "CPU speed: ", Sys::CPU::cpu_clock ();


 use System::Info;
 my $si = System::Info->new;
 say "CPU type : ", $si->get_cpu;         # or ->cpu
 say "CPU count: ", $si->get_core_count;  # or ->ncore
 say "CPU speed: ", $si->get_cpu =~ s{^.*\b([0-9.]+)\s*[A-Z]Hz.*}{$1}r;

The speed reported by Sys::CPU is the current speed, and it will change from call to call. YMMV.

Sys::CPU is not available on CPAN anymore, but you can still get is from BackPAN.


Devel::Platform::Info derives information from the files /etc/issue, /etc/.issue and the output of the commands uname -a (and -m, -o, -r, and -s) and lsb_release -a. It returns no information on CPU type, CPU speed, or Memory.

 use Devel::Platform::Info;
 my $info = Devel::Platform::Info->new->get_info ();


 use System::Info;
 my $si = System::Info->new;
 my $info = {
    archname => $si->cpu_type,
    codename => undef,
    is32bit  => undef,
    is64bit  => undef,
    kernel   => "$^O-".$si->_osvers,
    kname    => $si->_osname,
    kvers    => $si->_osvers,
    osflag   => $^O,
    oslabel  => $si->distro,
    osname   => undef,
    osvers   => $si->distro,


This one does not return the OS information as such, but features an alternative to $^O.


(c) 2016-2022, Abe Timmerman & H.Merijn Brand, All rights reserved.

With contributions from Jarkko Hietaniemi, Campo Weijerman, Alan Burlison, Allen Smith, Alain Barbet, Dominic Dunlop, Rich Rauenzahn, David Cantrell.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.