Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

How to tell 32 or 64 bit

by esr (Scribe)
on Oct 08, 2012 at 03:09 UTC ( #997731=perlquestion: print w/replies, xml ) Need Help??
esr has asked for the wisdom of the Perl Monks concerning the following question:

We recently had to purchase a new PC with Windows 7. I downloaded both the 32- and 64-bit versions from ActivePerl but I frankly can't remember which one I installed. Is there any way to tell now? The usual "uninstall or change a program" list in the Control Panel lists the Perl version number but not whether it is 32 or 64 bit.

Replies are listed 'Best First'.
Re: How to tell 32 or 64 bit
by bulk88 (Priest) on Oct 08, 2012 at 03:30 UTC
    A 32 bit perl.
    C:\p517\perl>perl -v This is perl 5, version 17, subversion 5 (v5.17.5 (v5.17.4-47-g432d456 +)) built for MSWin32-x86-multi-thread
    A 64 bit perl.
    C:\Documents and Settings\Administrator\Desktop>perl -v This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x +64-multi-thread
    To get it in a script
    C:\p517\perl>perl -MConfig -e "print $Config{archname}" MSWin32-x86-multi-thread C:\p517\perl>


      I just used your code:

      email7: perl -MConfig -E 'say $Config{archname};'
      for 4 different Perls built on Linux and 3 built on AIX/Unix computers and none of them had 32 or 64 in the response. I then looped on the %Config hash with 'grep 32' for all platforms and nothing looks consistent between Linux and AIX/Unix. If the original question was for Windows, I guess it works, but it doesn't seem to be a platform independent solution.

      Just a heads-up...Ed

      Update: After commenting, I reread the original post and you're solution was right on for windows.

      "Well done is better than well said." - Benjamin Franklin

Re: How to tell 32 or 64 bit
by salva (Abbot) on Oct 08, 2012 at 07:18 UTC
    perl -E 'say log(~0)/log(2)'


    Note that this command shows the number of bits on an IV, the type used internally by Perl to handle integers. Usually, it has the same number of bits as the CPU architecture but it is also possible to compile Perl for a 32 bits architecture while having 64 bits IVs. For instance, Debian does it.


      $ perl -wE'say log(~0)/log(2)' 64 $ perl -v This is perl 5, version 16, subversion 0 (v5.16.0) built for i686-linu +x-64int-ld $ ux Linux 3.4.6-2.10-desktop [openSUSE 12.2 (Mantis)] i386 Core(TM) i7-26 +20M CPU @ 2.70GHz/800(4) i686

      On 32bit systems I build my perl with -Duse64bitint and -Duselongdouble, so your statement will not work at all!

      Enjoy, Have FUN! H.Merijn
      $ perl -E 'say log(~0)/log(2)' 31.9999999996641

      Oh, damn. My bit is getting worn out.

      in the past I used that, but then I realized that 64 bit IVs but 32 bit pointers and machine code Perls existed, so it is wrong. Another good way to telling is
      perl -MConfig -e "print $Config{ptrsize}"
      which will return 4 or 8, and is NOT the IV size
Re: How to tell 32 or 64 bit
by ikegami (Pope) on Oct 10, 2012 at 02:06 UTC

    The pointer and integers size are independent.

    >perl -V:ptrsize ptrsize='4'; >perl -V:ivsize ivsize='4';

    You're probably talking about the ptrsize. (Multiply by 8.)

Re: How to tell 32 or 64 bit
by thomas895 (Chaplain) on Oct 09, 2012 at 04:01 UTC


    C:\> perl -MConfig -E "$t=[split(/-/,$Config{archname})]->[1];printf(q +{%d bit},$t eq "x86"?32:64)" 32 bit

    Only works on Windows, though.
    This is Just Another Way To Do It. :-)

    confess( "I offer no guarantees on my code." );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://997731]
Approved by davido
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2018-06-19 19:11 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (114 votes). Check out past polls.