Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi evrybody!
Does perl have some universal way for *nix system to know architecture of processor (x286, x586, x86 and etc)?

Replies are listed 'Best First'.
Re: Architecture of processor
by JavaFan (Canon) on Mar 04, 2009 at 12:39 UTC
    Assuming the Unix system is POSIX compliant
    print `uname -m`
    should do the trick. GNU uname also has -i, but that's not a POSIX requirement.

    And you could also look into $Config::Config{archname} and extract the architecture from that.

      Thanks! It exactly what I need.
Re: Architecture of processor
by slacker (Friar) on Mar 04, 2009 at 12:52 UTC
    If the above command is run on Solaris, you may run into an issue.
    Use
    uname -sp
    Read the Notes section here for details on that issue.
    Sun uname Manpage.
    In addition to uname, if you want any additional details about the processor, on Linux based systems.
    cat /proc/cpuinfo
Re: Architecture of processor
by Anonymous Monk on Mar 04, 2009 at 12:38 UTC