When in Solarisland, ask Solaris (pflags).

This one is ultra-fragile, but decide yourself if you can use or expand it!

use strict; use warnings; #-- returns 32 or 64, or 0 in case of error # optional argument: PID of another process; defaults to current PID # see also: http://docs.oracle.com/cd/E26502_01/html/E29030/pflags-1 +.html (pflags) # http://docs.oracle.com/cd/E26502_01/html/E28556/proc-pro +vider.html (psinfo_t section) # "...The pr_dmodel field is set to either PR_MODEL_ILP32, denoting +a 32bit process, # or PR_MODEL_LP64, denoting a 64bit process." # # WARNING! Tested under Solaris 10/11 only! # sub solaris_bits { my $pid = shift || $$; my $pflags = qx{LANG=C /usr/bin/pflags $pid 2>&1}; #-- "data model" should be '_ILP32' or '_LP64' return $pflags =~ /data model\s*=\s*\D*(\d+)/ms ? $1 : 0; } print "Bits (init): ", solaris_bits(1) || 'n/a' , "\n"; # PID==1 (need +s privileges!) print "Bits (self): ", solaris_bits() || 'n/a' , "\n"; # PID==$$

However, when checking bit-width for the current perl process ($pid == $$), I would rather use BrowserUks pack() approach.
There is also Solaris::Procfs but the bug-reports indicate, that it doesn't compile in a 64-bit environment. Nice opportunity to make this module work again (wink).


In reply to Re: I need to know if 32-bit or 64-bit perl is running my script. by Perlbotics
in thread I need to know if 32-bit or 64-bit perl is running my script. by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.