in reply to I need to know if 32-bit or 64-bit perl is running my script.
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).
|
|---|