Reputation: 1136
I want to determine if the Mac OS in 32 bit or 64 bit.
Who can write down the Perl script for me?
Upvotes: 2
Views: 583
Reputation: 386501
It's not clear what you want.
To find the instruction set used for perl
, you can use the following:
$ perl -V:myarchname
myarchname='x86_64-linux';
(As opposed to i686-linux
.)
To find the size of integers used by perl
, you can use the following:
$ perl -V:ivsize
ivsize='4';
(As opposed to 8
.)
These values can be accessed from within Perl as follows:
use Config qw( %Config );
say $Config{myarchname};
say $Config{ivsize};
Upvotes: 3
Reputation: 107080
You can check the output of uname -a
and see if it says i386
or x86_64
on the end:
#! /usr/bin/env perl
use strict;
use warnings;
use feature qw(say);
no warnings qw(uninitialized);
if (not -x "/usr/bin/uname") {
say "Can't determine system bit mode: uname command not found";
}
else {
chomp ( my $arch_type = qx(/usr/bin/uname -a) );
if (not $arch_type) {
say "Can't determine system bit mode";
}
elsif ($arch_type =~ /x86_64$/) {
say "System is in 64 bit mode";
}
else {
say "System is in 32 bit mode: $arch_type";
}
}
Upvotes: 1
Reputation: 6992
I'm no perl programmer, but how about trying to add 1 to the maximum 32bit integer and cheching it against the overflown value? If it equals, you're on 32bit...
Upvotes: 2
Reputation: 89549
One possibility would be to call "arch
".
A script I just quickly typed looks like this:
#!/usr/bin/perl -w
$arch=`arch`;
print $arch;
However, when I type in "arch
" at my Terminal command line, I get an output of "i386
". My Mac Pro tower is 64-bit capable (and some, if not all, apps run in 64-bit mode), so I'm not sure why I am not seeing "x86_64
" output instead.
Upvotes: 1