http://www.perlmonks.org?node_id=1054058


in reply to I need to know if 32-bit or 64-bit perl is running my script.

Should work anywhere:

C:\test>\perl64\bin\perl -e"print length pack 'P', -1" 8 C:\test>\perl32\bin\perl -e"print length pack 'P', -1" 4

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: I need to know if 32-bit or 64-bit perl is running my script.
by mbethke (Hermit) on Sep 14, 2013 at 06:58 UTC
    To see the userland code size that's a nice way. But if the kernel determines where stuff is placed in a struct and the kernel can run both 32- and 64-bit executables, you're still fuct. Plus some weird architectures like AS/400 (relevant for AIX) use 128bit pointers even on 32bit ALUs.
      But if the kernel determines where stuff is placed in a struct and the kernel can run both 32- and 64-bit executables, you're still fuct.

      That is certainly not the case for Intel processors. Even running under 64-bit kernels; 32-bit processes only use 32-bit pointers.

      Plus some weird architectures like AS/400 (relevant for AIX) use 128bit pointers even on 32bit ALUs.

      I know naff all about AS/400, but since the original AS/400 hardware was 48-bit; and it has all been 64-bit for the last decade or so; one wonders whether the question is even relevant for such hardware?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        True about the 32bit pointers, I just assumed Su^H^HOracle had changed something about the struct layout in 64bit versions. Otherwise the whole problem shouldn't exist as the change would be transparent to whatever C code retrieves the struct and passes it to Perl. In any case that's the leven the problem should be solved on. Actually I've never written anything for AS/400 either and especially with IBM's compatibility-back-to-the-60s fetishism you're right that it shouldn't matter at all. Wonder why the OP seemed to have a similar problem there.