Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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.

Comment on How to tell 32 or 64 bit
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>

      bulk88,

      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)'

    update:

    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 -E 'say log(~0)/log(2)' 31.9999999996641

      Oh, damn. My bit is getting worn out.

      UNTRUE!:

      $ 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
      length(pack('J',0))
      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 thomas895 (Hermit) on Oct 09, 2012 at 04:01 UTC

    Alternatively:

    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. :-)

    ~Thomas~
    confess( "I offer no guarantees on my code." );
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.)

Reaped: Re: How to tell 32 or 64 bit
by NodeReaper (Curate) on Oct 10, 2012 at 02:09 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://997731]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-12-29 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls